Passed
Pull Request — master (#847)
by Kiran
05:48
created
includes/wpinv-template-functions.php 2 patches
Indentation   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
141 141
  */
142 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 );
143
+    return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path );
144 144
 }
145 145
 
146 146
 /**
@@ -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
 /**
@@ -175,125 +175,125 @@  discard block
 block discarded – undo
175 175
 }
176 176
 
177 177
 function wpinv_get_template_part( $slug, $name = null, $load = true ) {
178
-	do_action( 'get_template_part_' . $slug, $slug, $name );
178
+    do_action( 'get_template_part_' . $slug, $slug, $name );
179 179
 
180
-	// Setup possible parts
181
-	$templates = array();
182
-	if ( isset( $name ) ) {
183
-		$templates[] = $slug . '-' . $name . '.php';
180
+    // Setup possible parts
181
+    $templates = array();
182
+    if ( isset( $name ) ) {
183
+        $templates[] = $slug . '-' . $name . '.php';
184 184
     }
185
-	$templates[] = $slug . '.php';
185
+    $templates[] = $slug . '.php';
186 186
 
187
-	// Allow template parts to be filtered
188
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
187
+    // Allow template parts to be filtered
188
+    $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
189 189
 
190
-	// Return the part that is found
191
-	return wpinv_locate_tmpl( $templates, $load, false );
190
+    // Return the part that is found
191
+    return wpinv_locate_tmpl( $templates, $load, false );
192 192
 }
193 193
 
194 194
 function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
195
-	// No file found yet
196
-	$located = false;
195
+    // No file found yet
196
+    $located = false;
197 197
 
198
-	// Try to find a template file
199
-	foreach ( (array)$template_names as $template_name ) {
198
+    // Try to find a template file
199
+    foreach ( (array)$template_names as $template_name ) {
200 200
 
201
-		// Continue if template is empty
202
-		if ( empty( $template_name ) ) {
203
-			continue;
201
+        // Continue if template is empty
202
+        if ( empty( $template_name ) ) {
203
+            continue;
204 204
         }
205 205
 
206
-		// Trim off any slashes from the template name
207
-		$template_name = ltrim( $template_name, '/' );
206
+        // Trim off any slashes from the template name
207
+        $template_name = ltrim( $template_name, '/' );
208 208
 
209
-		// try locating this template file by looping through the template paths
210
-		foreach ( wpinv_get_theme_template_paths() as $template_path ) {
209
+        // try locating this template file by looping through the template paths
210
+        foreach ( wpinv_get_theme_template_paths() as $template_path ) {
211 211
 
212
-			if ( file_exists( $template_path . $template_name ) ) {
213
-				$located = $template_path . $template_name;
214
-				break;
215
-			}
216
-		}
212
+            if ( file_exists( $template_path . $template_name ) ) {
213
+                $located = $template_path . $template_name;
214
+                break;
215
+            }
216
+        }
217 217
 
218
-		if ( ! empty( $located ) ) {
219
-			break;
220
-		}
221
-	}
218
+        if ( ! empty( $located ) ) {
219
+            break;
220
+        }
221
+    }
222 222
 
223
-	if ( ( true == $load ) && ! empty( $located ) ) {
224
-		load_template( $located, $require_once );
223
+    if ( ( true == $load ) && ! empty( $located ) ) {
224
+        load_template( $located, $require_once );
225 225
     }
226 226
 
227
-	return $located;
227
+    return $located;
228 228
 }
229 229
 
230 230
 function wpinv_get_theme_template_paths() {
231
-	$template_dir = wpinv_get_theme_template_dir_name();
231
+    $template_dir = wpinv_get_theme_template_dir_name();
232 232
 
233
-	$file_paths = array(
234
-		1   => trailingslashit( get_stylesheet_directory() ) . $template_dir,
235
-		10  => trailingslashit( get_template_directory() ) . $template_dir,
236
-		100 => wpinv_get_templates_dir(),
237
-	);
233
+    $file_paths = array(
234
+        1   => trailingslashit( get_stylesheet_directory() ) . $template_dir,
235
+        10  => trailingslashit( get_template_directory() ) . $template_dir,
236
+        100 => wpinv_get_templates_dir(),
237
+    );
238 238
 
239
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
239
+    $file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
240 240
 
241
-	// sort the file paths based on priority
242
-	ksort( $file_paths, SORT_NUMERIC );
241
+    // sort the file paths based on priority
242
+    ksort( $file_paths, SORT_NUMERIC );
243 243
 
244
-	return array_map( 'trailingslashit', $file_paths );
244
+    return array_map( 'trailingslashit', $file_paths );
245 245
 }
246 246
 
247 247
 function wpinv_checkout_meta_tags() {
248 248
 
249
-	$pages   = array();
250
-	$pages[] = wpinv_get_option( 'success_page' );
251
-	$pages[] = wpinv_get_option( 'failure_page' );
252
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
253
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
249
+    $pages   = array();
250
+    $pages[] = wpinv_get_option( 'success_page' );
251
+    $pages[] = wpinv_get_option( 'failure_page' );
252
+    $pages[] = wpinv_get_option( 'invoice_history_page' );
253
+    $pages[] = wpinv_get_option( 'invoice_subscription_page' );
254 254
 
255
-	if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) {
256
-		return;
257
-	}
255
+    if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) {
256
+        return;
257
+    }
258 258
 
259
-	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
259
+    echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
260 260
 }
261 261
 add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
262 262
 
263 263
 function wpinv_add_body_classes( $class ) {
264
-	$classes = (array)$class;
264
+    $classes = (array)$class;
265 265
 
266
-	if ( wpinv_is_checkout() ) {
267
-		$classes[] = 'wpinv-checkout';
268
-		$classes[] = 'wpinv-page';
269
-	}
266
+    if ( wpinv_is_checkout() ) {
267
+        $classes[] = 'wpinv-checkout';
268
+        $classes[] = 'wpinv-page';
269
+    }
270 270
 
271
-	if ( wpinv_is_success_page() ) {
272
-		$classes[] = 'wpinv-success';
273
-		$classes[] = 'wpinv-page';
274
-	}
271
+    if ( wpinv_is_success_page() ) {
272
+        $classes[] = 'wpinv-success';
273
+        $classes[] = 'wpinv-page';
274
+    }
275 275
 
276
-	if ( wpinv_is_failed_transaction_page() ) {
277
-		$classes[] = 'wpinv-failed-transaction';
278
-		$classes[] = 'wpinv-page';
279
-	}
276
+    if ( wpinv_is_failed_transaction_page() ) {
277
+        $classes[] = 'wpinv-failed-transaction';
278
+        $classes[] = 'wpinv-page';
279
+    }
280 280
 
281
-	if ( wpinv_is_invoice_history_page() ) {
282
-		$classes[] = 'wpinv-history';
283
-		$classes[] = 'wpinv-page';
284
-	}
281
+    if ( wpinv_is_invoice_history_page() ) {
282
+        $classes[] = 'wpinv-history';
283
+        $classes[] = 'wpinv-page';
284
+    }
285 285
 
286
-	if ( wpinv_is_subscriptions_history_page() ) {
287
-		$classes[] = 'wpinv-subscription';
288
-		$classes[] = 'wpinv-page';
289
-	}
286
+    if ( wpinv_is_subscriptions_history_page() ) {
287
+        $classes[] = 'wpinv-subscription';
288
+        $classes[] = 'wpinv-page';
289
+    }
290 290
 
291
-	if ( wpinv_is_test_mode() ) {
292
-		$classes[] = 'wpinv-test-mode';
293
-		$classes[] = 'wpinv-page';
294
-	}
291
+    if ( wpinv_is_test_mode() ) {
292
+        $classes[] = 'wpinv-test-mode';
293
+        $classes[] = 'wpinv-page';
294
+    }
295 295
 
296
-	return array_unique( $classes );
296
+    return array_unique( $classes );
297 297
 }
298 298
 add_filter( 'body_class', 'wpinv_add_body_classes' );
299 299
 
@@ -467,16 +467,16 @@  discard block
 block discarded – undo
467 467
 
468 468
     wpinv_html_select(
469 469
         array(
470
-			'name'             => $args['name'],
471
-			'selected'         => $args['selected'],
472
-			'id'               => $args['id'],
473
-			'class'            => $args['class'],
474
-			'options'          => $options,
475
-			'multiple'         => $args['multiple'],
476
-			'placeholder'      => $args['placeholder'],
477
-			'show_option_all'  => $args['show_option_all'],
478
-			'show_option_none' => $args['show_option_none'],
479
-			'data'             => $args['data'],
470
+            'name'             => $args['name'],
471
+            'selected'         => $args['selected'],
472
+            'id'               => $args['id'],
473
+            'class'            => $args['class'],
474
+            'options'          => $options,
475
+            'multiple'         => $args['multiple'],
476
+            'placeholder'      => $args['placeholder'],
477
+            'show_option_all'  => $args['show_option_all'],
478
+            'show_option_none' => $args['show_option_none'],
479
+            'data'             => $args['data'],
480 480
         )
481 481
     );
482 482
 
@@ -776,21 +776,21 @@  discard block
 block discarded – undo
776 776
 
777 777
     $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
778 778
 
779
-	// Remove unavailable tags.
779
+    // Remove unavailable tags.
780 780
     $formatted_address = preg_replace( '/\{\{\w+\}\}/', '', $formatted_address );
781 781
 
782 782
     // Clean up white space.
783
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
783
+    $formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
784 784
     $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
785 785
 
786 786
     // Break newlines apart and remove empty lines/trim commas and white space.
787
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
787
+    $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
788 788
 
789 789
     // Add html breaks.
790
-	$formatted_address = implode( $separator, $formatted_address );
790
+    $formatted_address = implode( $separator, $formatted_address );
791 791
 
792
-	// We're done!
793
-	return $formatted_address;
792
+    // We're done!
793
+    return $formatted_address;
794 794
 
795 795
 }
796 796
 
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
 function getpaid_display_invoice_subscriptions( $invoice ) {
837 837
 
838 838
     // Subscriptions.
839
-	$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
839
+    $subscriptions = getpaid_get_invoice_subscriptions( $invoice );
840 840
 
841 841
     if ( empty( $subscriptions ) || ! $invoice->is_recurring() ) {
842 842
         return;
@@ -1052,7 +1052,7 @@  discard block
 block discarded – undo
1052 1052
 }
1053 1053
 
1054 1054
 function wpinv_empty_cart_message() {
1055
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1055
+    return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1056 1056
 }
1057 1057
 
1058 1058
 /**
@@ -1250,9 +1250,9 @@  discard block
 block discarded – undo
1250 1250
 
1251 1251
     if ( 0 == count( $form->get_items() ) ) {
1252 1252
         aui()->alert(
1253
-			array(
1254
-				'type'    => 'warning',
1255
-				'content' => __( 'No published items found', 'invoicing' ),
1253
+            array(
1254
+                'type'    => 'warning',
1255
+                'content' => __( 'No published items found', 'invoicing' ),
1256 1256
             ),
1257 1257
             true
1258 1258
         );
@@ -1275,10 +1275,10 @@  discard block
 block discarded – undo
1275 1275
     $invoice = wpinv_get_invoice( $invoice_id );
1276 1276
 
1277 1277
     if ( empty( $invoice ) ) {
1278
-		aui()->alert(
1279
-			array(
1280
-				'type'    => 'warning',
1281
-				'content' => __( 'Invoice not found', 'invoicing' ),
1278
+        aui()->alert(
1279
+            array(
1280
+                'type'    => 'warning',
1281
+                'content' => __( 'Invoice not found', 'invoicing' ),
1282 1282
             ),
1283 1283
             true
1284 1284
         );
@@ -1286,10 +1286,10 @@  discard block
 block discarded – undo
1286 1286
     }
1287 1287
 
1288 1288
     if ( $invoice->is_paid() ) {
1289
-		aui()->alert(
1290
-			array(
1291
-				'type'    => 'warning',
1292
-				'content' => __( 'Invoice has already been paid', 'invoicing' ),
1289
+        aui()->alert(
1290
+            array(
1291
+                'type'    => 'warning',
1292
+                'content' => __( 'Invoice has already been paid', 'invoicing' ),
1293 1293
             ),
1294 1294
             true
1295 1295
         );
@@ -1354,7 +1354,7 @@  discard block
 block discarded – undo
1354 1354
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>";
1355 1355
     }
1356 1356
 
1357
-	if ( ! empty( $items ) ) {
1357
+    if ( ! empty( $items ) ) {
1358 1358
         $items  = esc_attr( $items );
1359 1359
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>";
1360 1360
     }
@@ -1554,21 +1554,21 @@  discard block
 block discarded – undo
1554 1554
 
1555 1555
         return aui()->select(
1556 1556
             array(
1557
-				'options'          => $states,
1558
-				'name'             => esc_attr( $field_name ),
1559
-				'id'               => sanitize_html_class( $field_name ) . $uniqid,
1560
-				'value'            => sanitize_text_field( $state ),
1561
-				'placeholder'      => $placeholder,
1562
-				'required'         => $required,
1563
-				'label'            => wp_kses_post( $label ),
1564
-				'label_type'       => 'vertical',
1565
-				'help_text'        => $help_text,
1566
-				'class'            => 'getpaid-address-field wpinv_state',
1567
-				'wrap_class'       => "$wrapper_class getpaid-address-field-wrapper__state",
1568
-				'label_class'      => 'getpaid-address-field-label getpaid-address-field-label__state',
1569
-				'extra_attributes' => array(
1570
-					'autocomplete' => 'address-level1',
1571
-				),
1557
+                'options'          => $states,
1558
+                'name'             => esc_attr( $field_name ),
1559
+                'id'               => sanitize_html_class( $field_name ) . $uniqid,
1560
+                'value'            => sanitize_text_field( $state ),
1561
+                'placeholder'      => $placeholder,
1562
+                'required'         => $required,
1563
+                'label'            => wp_kses_post( $label ),
1564
+                'label_type'       => 'vertical',
1565
+                'help_text'        => $help_text,
1566
+                'class'            => 'getpaid-address-field wpinv_state',
1567
+                'wrap_class'       => "$wrapper_class getpaid-address-field-wrapper__state",
1568
+                'label_class'      => 'getpaid-address-field-label getpaid-address-field-label__state',
1569
+                'extra_attributes' => array(
1570
+                    'autocomplete' => 'address-level1',
1571
+                ),
1572 1572
             ),
1573 1573
             $echo
1574 1574
         );
@@ -1664,34 +1664,34 @@  discard block
 block discarded – undo
1664 1664
  * @return array Array of custom fields.
1665 1665
  */
1666 1666
 function getpaid_get_payment_form_custom_fields() {
1667
-	global $wpdb, $payment_form_meta_fields;
1667
+    global $wpdb, $payment_form_meta_fields;
1668 1668
 
1669
-	if ( ! empty( $payment_form_meta_fields ) ) {
1670
-		return $payment_form_meta_fields;
1671
-	}
1669
+    if ( ! empty( $payment_form_meta_fields ) ) {
1670
+        return $payment_form_meta_fields;
1671
+    }
1672 1672
 
1673
-	$results = $wpdb->get_results( "SELECT `pm`.`meta_value` FROM `{$wpdb->postmeta}` AS pm LEFT JOIN `{$wpdb->posts}` AS p ON p.ID = pm.post_id WHERE `pm`.`meta_key` = 'wpinv_form_elements' AND `p`.`post_type` = 'wpi_payment_form'" );
1673
+    $results = $wpdb->get_results( "SELECT `pm`.`meta_value` FROM `{$wpdb->postmeta}` AS pm LEFT JOIN `{$wpdb->posts}` AS p ON p.ID = pm.post_id WHERE `pm`.`meta_key` = 'wpinv_form_elements' AND `p`.`post_type` = 'wpi_payment_form'" );
1674 1674
 
1675
-	$meta_fields = array();
1675
+    $meta_fields = array();
1676 1676
 
1677
-	if ( ! empty( $results ) ) {
1678
-		foreach ( $results as $row ) {
1679
-			$fields = maybe_unserialize( $row->meta_value );
1677
+    if ( ! empty( $results ) ) {
1678
+        foreach ( $results as $row ) {
1679
+            $fields = maybe_unserialize( $row->meta_value );
1680 1680
 
1681
-			if ( ! empty( $fields ) && is_array( $fields ) ) {
1682
-				foreach ( $fields as $field ) {
1683
-					$label = ! empty( $field['add_meta'] ) && ! empty( $field['label'] ) ? wpinv_clean( wp_unslash( $field['label'] ) ) : '';
1681
+            if ( ! empty( $fields ) && is_array( $fields ) ) {
1682
+                foreach ( $fields as $field ) {
1683
+                    $label = ! empty( $field['add_meta'] ) && ! empty( $field['label'] ) ? wpinv_clean( wp_unslash( $field['label'] ) ) : '';
1684 1684
 
1685
-					if ( $label ) {
1686
-						$field_key = '_' . str_replace( array( ' ', "'", '"', ',' ), array( '_', '', '', '_' ), getpaid_strtolower( $label ) );
1687
-						$meta_fields[ $field_key ] = $label;
1688
-					}
1689
-				}
1690
-			}
1691
-		}
1692
-	}
1685
+                    if ( $label ) {
1686
+                        $field_key = '_' . str_replace( array( ' ', "'", '"', ',' ), array( '_', '', '', '_' ), getpaid_strtolower( $label ) );
1687
+                        $meta_fields[ $field_key ] = $label;
1688
+                    }
1689
+                }
1690
+            }
1691
+        }
1692
+    }
1693 1693
 
1694
-	$payment_form_meta_fields = $meta_fields;
1694
+    $payment_form_meta_fields = $meta_fields;
1695 1695
 
1696
-	return $meta_fields;
1696
+    return $meta_fields;
1697 1697
 }
Please login to merge, or discard this patch.
Spacing   +462 added lines, -462 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, 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
-    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
+    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,58 +170,58 @@  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
     }
185 185
 	$templates[] = $slug . '.php';
186 186
 
187 187
 	// Allow template parts to be filtered
188
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
188
+	$templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name);
189 189
 
190 190
 	// Return the part that is found
191
-	return wpinv_locate_tmpl( $templates, $load, false );
191
+	return wpinv_locate_tmpl($templates, $load, false);
192 192
 }
193 193
 
194
-function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
194
+function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) {
195 195
 	// No file found yet
196 196
 	$located = false;
197 197
 
198 198
 	// Try to find a template file
199
-	foreach ( (array)$template_names as $template_name ) {
199
+	foreach ((array) $template_names as $template_name) {
200 200
 
201 201
 		// Continue if template is empty
202
-		if ( empty( $template_name ) ) {
202
+		if (empty($template_name)) {
203 203
 			continue;
204 204
         }
205 205
 
206 206
 		// Trim off any slashes from the template name
207
-		$template_name = ltrim( $template_name, '/' );
207
+		$template_name = ltrim($template_name, '/');
208 208
 
209 209
 		// try locating this template file by looping through the template paths
210
-		foreach ( wpinv_get_theme_template_paths() as $template_path ) {
210
+		foreach (wpinv_get_theme_template_paths() as $template_path) {
211 211
 
212
-			if ( file_exists( $template_path . $template_name ) ) {
212
+			if (file_exists($template_path . $template_name)) {
213 213
 				$located = $template_path . $template_name;
214 214
 				break;
215 215
 			}
216 216
 		}
217 217
 
218
-		if ( ! empty( $located ) ) {
218
+		if (!empty($located)) {
219 219
 			break;
220 220
 		}
221 221
 	}
222 222
 
223
-	if ( ( true == $load ) && ! empty( $located ) ) {
224
-		load_template( $located, $require_once );
223
+	if ((true == $load) && !empty($located)) {
224
+		load_template($located, $require_once);
225 225
     }
226 226
 
227 227
 	return $located;
@@ -231,73 +231,73 @@  discard block
 block discarded – undo
231 231
 	$template_dir = wpinv_get_theme_template_dir_name();
232 232
 
233 233
 	$file_paths = array(
234
-		1   => trailingslashit( get_stylesheet_directory() ) . $template_dir,
235
-		10  => trailingslashit( get_template_directory() ) . $template_dir,
234
+		1   => trailingslashit(get_stylesheet_directory()) . $template_dir,
235
+		10  => trailingslashit(get_template_directory()) . $template_dir,
236 236
 		100 => wpinv_get_templates_dir(),
237 237
 	);
238 238
 
239
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
239
+	$file_paths = apply_filters('wpinv_template_paths', $file_paths);
240 240
 
241 241
 	// sort the file paths based on priority
242
-	ksort( $file_paths, SORT_NUMERIC );
242
+	ksort($file_paths, SORT_NUMERIC);
243 243
 
244
-	return array_map( 'trailingslashit', $file_paths );
244
+	return array_map('trailingslashit', $file_paths);
245 245
 }
246 246
 
247 247
 function wpinv_checkout_meta_tags() {
248 248
 
249 249
 	$pages   = array();
250
-	$pages[] = wpinv_get_option( 'success_page' );
251
-	$pages[] = wpinv_get_option( 'failure_page' );
252
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
253
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
250
+	$pages[] = wpinv_get_option('success_page');
251
+	$pages[] = wpinv_get_option('failure_page');
252
+	$pages[] = wpinv_get_option('invoice_history_page');
253
+	$pages[] = wpinv_get_option('invoice_subscription_page');
254 254
 
255
-	if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) {
255
+	if (!wpinv_is_checkout() && !is_page($pages)) {
256 256
 		return;
257 257
 	}
258 258
 
259 259
 	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
260 260
 }
261
-add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
261
+add_action('wp_head', 'wpinv_checkout_meta_tags');
262 262
 
263
-function wpinv_add_body_classes( $class ) {
264
-	$classes = (array)$class;
263
+function wpinv_add_body_classes($class) {
264
+	$classes = (array) $class;
265 265
 
266
-	if ( wpinv_is_checkout() ) {
266
+	if (wpinv_is_checkout()) {
267 267
 		$classes[] = 'wpinv-checkout';
268 268
 		$classes[] = 'wpinv-page';
269 269
 	}
270 270
 
271
-	if ( wpinv_is_success_page() ) {
271
+	if (wpinv_is_success_page()) {
272 272
 		$classes[] = 'wpinv-success';
273 273
 		$classes[] = 'wpinv-page';
274 274
 	}
275 275
 
276
-	if ( wpinv_is_failed_transaction_page() ) {
276
+	if (wpinv_is_failed_transaction_page()) {
277 277
 		$classes[] = 'wpinv-failed-transaction';
278 278
 		$classes[] = 'wpinv-page';
279 279
 	}
280 280
 
281
-	if ( wpinv_is_invoice_history_page() ) {
281
+	if (wpinv_is_invoice_history_page()) {
282 282
 		$classes[] = 'wpinv-history';
283 283
 		$classes[] = 'wpinv-page';
284 284
 	}
285 285
 
286
-	if ( wpinv_is_subscriptions_history_page() ) {
286
+	if (wpinv_is_subscriptions_history_page()) {
287 287
 		$classes[] = 'wpinv-subscription';
288 288
 		$classes[] = 'wpinv-page';
289 289
 	}
290 290
 
291
-	if ( wpinv_is_test_mode() ) {
291
+	if (wpinv_is_test_mode()) {
292 292
 		$classes[] = 'wpinv-test-mode';
293 293
 		$classes[] = 'wpinv-page';
294 294
 	}
295 295
 
296
-	return array_unique( $classes );
296
+	return array_unique($classes);
297 297
 }
298
-add_filter( 'body_class', 'wpinv_add_body_classes' );
298
+add_filter('body_class', 'wpinv_add_body_classes');
299 299
 
300
-function wpinv_html_select( $args = array() ) {
300
+function wpinv_html_select($args = array()) {
301 301
     $defaults = array(
302 302
         'options'          => array(),
303 303
         'name'             => null,
@@ -306,8 +306,8 @@  discard block
 block discarded – undo
306 306
         'selected'         => 0,
307 307
         'placeholder'      => null,
308 308
         'multiple'         => false,
309
-        'show_option_all'  => _x( 'All', 'all dropdown items', 'invoicing' ),
310
-        'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ),
309
+        'show_option_all'  => _x('All', 'all dropdown items', 'invoicing'),
310
+        'show_option_none' => _x('None', 'no dropdown items', 'invoicing'),
311 311
         'data'             => array(),
312 312
         'onchange'         => null,
313 313
         'required'         => false,
@@ -315,79 +315,79 @@  discard block
 block discarded – undo
315 315
         'readonly'         => false,
316 316
     );
317 317
 
318
-    $args = wp_parse_args( $args, $defaults );
318
+    $args = wp_parse_args($args, $defaults);
319 319
 
320 320
     $attrs = array(
321 321
         'name'     => $args['name'],
322 322
         'id'       => $args['id'],
323
-        'class'    => 'wpinv-select ' . implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ),
324
-        'multiple' => ! empty( $args['multiple'] ),
325
-        'readonly' => ! empty( $args['readonly'] ),
326
-        'disabled' => ! empty( $args['disabled'] ),
327
-        'required' => ! empty( $args['required'] ),
328
-        'onchange' => ! empty( $args['onchange'] ),
323
+        'class'    => 'wpinv-select ' . implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))),
324
+        'multiple' => !empty($args['multiple']),
325
+        'readonly' => !empty($args['readonly']),
326
+        'disabled' => !empty($args['disabled']),
327
+        'required' => !empty($args['required']),
328
+        'onchange' => !empty($args['onchange']),
329 329
     );
330 330
 
331
-    if ( $args['placeholder'] ) {
331
+    if ($args['placeholder']) {
332 332
         $attrs['data-placeholder'] = $args['placeholder'];
333 333
     }
334 334
 
335
-    if ( $args['onchange'] ) {
335
+    if ($args['onchange']) {
336 336
         $attrs['onchange'] = $args['onchange'];
337 337
     }
338 338
 
339
-    foreach ( $args['data'] as $key => $value ) {
339
+    foreach ($args['data'] as $key => $value) {
340 340
         $attrs["data-$key"] = $value;
341 341
     }
342 342
 
343 343
     echo '<select ';
344 344
 
345
-    foreach ( $attrs as $attr => $value ) {
345
+    foreach ($attrs as $attr => $value) {
346 346
 
347
-        if ( false === $value ) {
347
+        if (false === $value) {
348 348
             continue;
349 349
         }
350 350
 
351
-        if ( true === $value ) {
352
-            echo ' ' . esc_attr( $attr );
351
+        if (true === $value) {
352
+            echo ' ' . esc_attr($attr);
353 353
         } else {
354
-            echo ' ' . esc_attr( $attr ) . '="' . esc_attr( $value ) . '"';
354
+            echo ' ' . esc_attr($attr) . '="' . esc_attr($value) . '"';
355 355
         }
356 356
 
357 357
     }
358 358
 
359 359
     echo '>';
360 360
 
361
-    if ( $args['show_option_all'] ) {
362
-        if ( $args['multiple'] ) {
363
-            $selected = in_array( 0, $args['selected'] );
361
+    if ($args['show_option_all']) {
362
+        if ($args['multiple']) {
363
+            $selected = in_array(0, $args['selected']);
364 364
         } else {
365
-            $selected = empty( $args['selected'] );
365
+            $selected = empty($args['selected']);
366 366
         }
367
-        echo '<option value="all"' . selected( $selected, true, false ) . '>' . esc_html( $args['show_option_all'] ) . '</option>';
367
+        echo '<option value="all"' . selected($selected, true, false) . '>' . esc_html($args['show_option_all']) . '</option>';
368 368
     }
369 369
 
370
-    if ( ! empty( $args['options'] ) ) {
370
+    if (!empty($args['options'])) {
371 371
 
372
-        if ( $args['show_option_none'] ) {
373
-            if ( $args['multiple'] ) {
374
-                $selected = in_array( '', $args['selected'], true );
372
+        if ($args['show_option_none']) {
373
+            if ($args['multiple']) {
374
+                $selected = in_array('', $args['selected'], true);
375 375
             } else {
376 376
                 $selected = $args['selected'] === '';
377 377
             }
378 378
 
379
-            echo '<option value=""' . selected( $selected, true, false ) . '>' . esc_html( $args['show_option_none'] ) . '</option>';
379
+            echo '<option value=""' . selected($selected, true, false) . '>' . esc_html($args['show_option_none']) . '</option>';
380 380
         }
381 381
 
382
-        foreach ( $args['options'] as $key => $option ) {
382
+        foreach ($args['options'] as $key => $option) {
383 383
 
384
-            if ( $args['multiple'] && is_array( $args['selected'] ) ) {
385
-                $selected = in_array( $key, $args['selected'], true );
384
+            if ($args['multiple'] && is_array($args['selected'])) {
385
+                $selected = in_array($key, $args['selected'], true);
386 386
             } else {
387 387
                 $selected = $args['selected'] === $key;
388 388
             }
389 389
 
390
-            echo '<option value="' . esc_attr( $key ) . '"' . selected( $selected, true, false ) . '>' . esc_html( $option ) . '</option>';
390
+            echo '<option value="' . esc_attr($key) . '"' . selected($selected, true, false) . '>' . esc_html($option) . '</option>';
391 391
         }
392 392
     }
393 393
 
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 
396 396
 }
397 397
 
398
-function wpinv_item_dropdown( $args = array() ) {
398
+function wpinv_item_dropdown($args = array()) {
399 399
     $defaults = array(
400 400
         'name'             => 'wpi_item',
401 401
         'id'               => 'wpi_item',
@@ -403,14 +403,14 @@  discard block
 block discarded – undo
403 403
         'multiple'         => false,
404 404
         'selected'         => 0,
405 405
         'number'           => -1,
406
-        'placeholder'      => __( 'Choose a item', 'invoicing' ),
407
-        'data'             => array( 'search-type' => 'item' ),
406
+        'placeholder'      => __('Choose a item', 'invoicing'),
407
+        'data'             => array('search-type' => 'item'),
408 408
         'show_option_all'  => false,
409 409
         'show_option_none' => false,
410 410
         'show_recurring'   => false,
411 411
     );
412 412
 
413
-    $args = wp_parse_args( $args, $defaults );
413
+    $args = wp_parse_args($args, $defaults);
414 414
 
415 415
     $item_args = array(
416 416
         'post_type'      => 'wpi_item',
@@ -428,40 +428,40 @@  discard block
 block discarded – undo
428 428
         ),
429 429
     );
430 430
 
431
-    $item_args  = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults );
431
+    $item_args  = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults);
432 432
 
433
-    $items      = get_posts( $item_args );
433
+    $items      = get_posts($item_args);
434 434
     $options    = array();
435
-    if ( $items ) {
436
-        foreach ( $items as $item ) {
437
-            $title = esc_html( $item->post_title );
435
+    if ($items) {
436
+        foreach ($items as $item) {
437
+            $title = esc_html($item->post_title);
438 438
 
439
-            if ( ! empty( $args['show_recurring'] ) ) {
440
-                $title .= wpinv_get_item_suffix( $item->ID, false );
439
+            if (!empty($args['show_recurring'])) {
440
+                $title .= wpinv_get_item_suffix($item->ID, false);
441 441
             }
442 442
 
443
-            $options[ absint( $item->ID ) ] = $title;
443
+            $options[absint($item->ID)] = $title;
444 444
         }
445 445
     }
446 446
 
447 447
     // This ensures that any selected items are included in the drop down
448
-    if ( is_array( $args['selected'] ) ) {
449
-        foreach ( $args['selected'] as $item ) {
450
-            if ( ! in_array( $item, $options ) ) {
451
-                $title = get_the_title( $item );
452
-                if ( ! empty( $args['show_recurring'] ) ) {
453
-                    $title .= wpinv_get_item_suffix( $item, false );
448
+    if (is_array($args['selected'])) {
449
+        foreach ($args['selected'] as $item) {
450
+            if (!in_array($item, $options)) {
451
+                $title = get_the_title($item);
452
+                if (!empty($args['show_recurring'])) {
453
+                    $title .= wpinv_get_item_suffix($item, false);
454 454
                 }
455
-                $options[ $item ] = $title;
455
+                $options[$item] = $title;
456 456
             }
457 457
         }
458
-    } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) {
459
-        if ( ! in_array( $args['selected'], $options ) ) {
460
-            $title = get_the_title( $args['selected'] );
461
-            if ( ! empty( $args['show_recurring'] ) ) {
462
-                $title .= wpinv_get_item_suffix( $args['selected'], false );
458
+    } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
459
+        if (!in_array($args['selected'], $options)) {
460
+            $title = get_the_title($args['selected']);
461
+            if (!empty($args['show_recurring'])) {
462
+                $title .= wpinv_get_item_suffix($args['selected'], false);
463 463
             }
464
-            $options[ $args['selected'] ] = get_the_title( $args['selected'] );
464
+            $options[$args['selected']] = get_the_title($args['selected']);
465 465
         }
466 466
     }
467 467
 
@@ -497,16 +497,16 @@  discard block
 block discarded – undo
497 497
     );
498 498
 
499 499
     $options = array();
500
-    if ( $items ) {
501
-        foreach ( $items as $item ) {
502
-            $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false );
500
+    if ($items) {
501
+        foreach ($items as $item) {
502
+            $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false);
503 503
         }
504 504
     }
505 505
 
506 506
     return $options;
507 507
 }
508 508
 
509
-function wpinv_html_checkbox( $args = array() ) {
509
+function wpinv_html_checkbox($args = array()) {
510 510
     $defaults = array(
511 511
         'name'    => null,
512 512
         'current' => null,
@@ -517,17 +517,17 @@  discard block
 block discarded – undo
517 517
         ),
518 518
     );
519 519
 
520
-    $args = wp_parse_args( $args, $defaults );
520
+    $args = wp_parse_args($args, $defaults);
521 521
 
522
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
522
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
523 523
     $attr  = '';
524
-    if ( ! empty( $args['options']['disabled'] ) ) {
524
+    if (!empty($args['options']['disabled'])) {
525 525
         $attr .= ' disabled="disabled"';
526
-    } elseif ( ! empty( $args['options']['readonly'] ) ) {
526
+    } elseif (!empty($args['options']['readonly'])) {
527 527
         $attr .= ' readonly';
528 528
     }
529 529
 
530
-    $output = '<input type="checkbox"' . $attr . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . esc_attr( $class ) . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />';
530
+    $output = '<input type="checkbox"' . $attr . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . esc_attr($class) . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />';
531 531
 
532 532
     return $output;
533 533
 }
@@ -535,34 +535,34 @@  discard block
 block discarded – undo
535 535
 /**
536 536
  * Displays a hidden field.
537 537
  */
538
-function getpaid_hidden_field( $name, $value ) {
539
-    echo "<input type='hidden' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "' />";
538
+function getpaid_hidden_field($name, $value) {
539
+    echo "<input type='hidden' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' />";
540 540
 }
541 541
 
542 542
 /**
543 543
  * Displays a submit field.
544 544
  */
545
-function getpaid_submit_field( $value, $name = 'submit', $class = 'btn-primary' ) {
546
-    echo "<input type='submit' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "' class='btn " . esc_attr( $class ) . "' />";
545
+function getpaid_submit_field($value, $name = 'submit', $class = 'btn-primary') {
546
+    echo "<input type='submit' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' class='btn " . esc_attr($class) . "' />";
547 547
 }
548 548
 
549
-function wpinv_html_text( $args = array() ) {
549
+function wpinv_html_text($args = array()) {
550 550
     // Backwards compatibility
551
-    if ( func_num_args() > 1 ) {
551
+    if (func_num_args() > 1) {
552 552
         $args = func_get_args();
553 553
 
554 554
         $name  = $args[0];
555
-        $value = isset( $args[1] ) ? $args[1] : '';
556
-        $label = isset( $args[2] ) ? $args[2] : '';
557
-        $desc  = isset( $args[3] ) ? $args[3] : '';
555
+        $value = isset($args[1]) ? $args[1] : '';
556
+        $label = isset($args[2]) ? $args[2] : '';
557
+        $desc  = isset($args[3]) ? $args[3] : '';
558 558
     }
559 559
 
560 560
     $defaults = array(
561 561
         'id'           => '',
562
-        'name'         => isset( $name ) ? $name : 'text',
563
-        'value'        => isset( $value ) ? $value : null,
564
-        'label'        => isset( $label ) ? $label : null,
565
-        'desc'         => isset( $desc ) ? $desc : null,
562
+        'name'         => isset($name) ? $name : 'text',
563
+        'value'        => isset($value) ? $value : null,
564
+        'label'        => isset($label) ? $label : null,
565
+        'desc'         => isset($desc) ? $desc : null,
566 566
         'placeholder'  => '',
567 567
         'class'        => 'regular-text',
568 568
         'disabled'     => false,
@@ -572,41 +572,41 @@  discard block
 block discarded – undo
572 572
         'data'         => false,
573 573
     );
574 574
 
575
-    $args = wp_parse_args( $args, $defaults );
575
+    $args = wp_parse_args($args, $defaults);
576 576
 
577
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
577
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
578 578
     $options = '';
579
-    if ( $args['required'] ) {
579
+    if ($args['required']) {
580 580
         $options .= ' required="required"';
581 581
     }
582
-    if ( $args['readonly'] ) {
582
+    if ($args['readonly']) {
583 583
         $options .= ' readonly';
584 584
     }
585
-    if ( $args['readonly'] ) {
585
+    if ($args['readonly']) {
586 586
         $options .= ' readonly';
587 587
     }
588 588
 
589 589
     $data = '';
590
-    if ( ! empty( $args['data'] ) ) {
591
-        foreach ( $args['data'] as $key => $value ) {
592
-            $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" ';
590
+    if (!empty($args['data'])) {
591
+        foreach ($args['data'] as $key => $value) {
592
+            $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" ';
593 593
         }
594 594
     }
595 595
 
596
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
597
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
598
-    if ( ! empty( $args['desc'] ) ) {
599
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
596
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
597
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>';
598
+    if (!empty($args['desc'])) {
599
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
600 600
     }
601 601
 
602
-    $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 ) . '/>';
602
+    $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) . '/>';
603 603
 
604 604
     $output .= '</span>';
605 605
 
606 606
     return $output;
607 607
 }
608 608
 
609
-function wpinv_html_textarea( $args = array() ) {
609
+function wpinv_html_textarea($args = array()) {
610 610
     $defaults = array(
611 611
         'name'        => 'textarea',
612 612
         'value'       => null,
@@ -617,31 +617,31 @@  discard block
 block discarded – undo
617 617
         'placeholder' => '',
618 618
     );
619 619
 
620
-    $args = wp_parse_args( $args, $defaults );
620
+    $args = wp_parse_args($args, $defaults);
621 621
 
622
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
622
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
623 623
     $disabled = '';
624
-    if ( $args['disabled'] ) {
624
+    if ($args['disabled']) {
625 625
         $disabled = ' disabled="disabled"';
626 626
     }
627 627
 
628
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
629
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
630
-    $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>';
628
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
629
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>';
630
+    $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>';
631 631
 
632
-    if ( ! empty( $args['desc'] ) ) {
633
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
632
+    if (!empty($args['desc'])) {
633
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
634 634
     }
635 635
     $output .= '</span>';
636 636
 
637 637
     return $output;
638 638
 }
639 639
 
640
-function wpinv_html_ajax_user_search( $args = array() ) {
640
+function wpinv_html_ajax_user_search($args = array()) {
641 641
     $defaults = array(
642 642
         'name'         => 'user_id',
643 643
         'value'        => null,
644
-        'placeholder'  => __( 'Enter username', 'invoicing' ),
644
+        'placeholder'  => __('Enter username', 'invoicing'),
645 645
         'label'        => null,
646 646
         'desc'         => null,
647 647
         'class'        => '',
@@ -650,13 +650,13 @@  discard block
 block discarded – undo
650 650
         'data'         => false,
651 651
     );
652 652
 
653
-    $args = wp_parse_args( $args, $defaults );
653
+    $args = wp_parse_args($args, $defaults);
654 654
 
655 655
     $args['class'] = 'wpinv-ajax-user-search ' . $args['class'];
656 656
 
657 657
     $output  = '<span class="wpinv_user_search_wrap">';
658
-        $output .= wpinv_html_text( $args );
659
-        $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>';
658
+        $output .= wpinv_html_text($args);
659
+        $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>';
660 660
     $output .= '</span>';
661 661
 
662 662
     return $output;
@@ -667,44 +667,44 @@  discard block
 block discarded – undo
667 667
  *
668 668
  * @param string $template the template that is currently being used.
669 669
  */
670
-function wpinv_template( $template ) {
670
+function wpinv_template($template) {
671 671
     global $post;
672 672
 
673
-    if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) {
673
+    if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) {
674 674
 
675 675
         // If the user can view this invoice, display it.
676
-        if ( wpinv_user_can_view_invoice( $post->ID ) ) {
676
+        if (wpinv_user_can_view_invoice($post->ID)) {
677 677
 
678
-            return wpinv_get_template_part( 'wpinv-invoice-print', false, false );
678
+            return wpinv_get_template_part('wpinv-invoice-print', false, false);
679 679
 
680 680
         // Else display an error message.
681 681
         } else {
682 682
 
683
-            return wpinv_get_template_part( 'wpinv-invalid-access', false, false );
683
+            return wpinv_get_template_part('wpinv-invalid-access', false, false);
684 684
 
685 685
         }
686 686
 }
687 687
 
688 688
     return $template;
689 689
 }
690
-add_filter( 'template_include', 'wpinv_template', 1000, 1 );
690
+add_filter('template_include', 'wpinv_template', 1000, 1);
691 691
 
692 692
 function wpinv_get_business_address() {
693 693
     $business_address   = wpinv_store_address();
694
-    $business_address   = ! empty( $business_address ) ? wp_kses_post( wpautop( $business_address ) ) : '';
694
+    $business_address   = !empty($business_address) ? wp_kses_post(wpautop($business_address)) : '';
695 695
 
696 696
     $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : '';
697 697
 
698
-    return apply_filters( 'wpinv_get_business_address', $business_address );
698
+    return apply_filters('wpinv_get_business_address', $business_address);
699 699
 }
700 700
 
701 701
 /**
702 702
  * Displays the company address.
703 703
  */
704 704
 function wpinv_display_from_address() {
705
-    wpinv_get_template( 'invoice/company-address.php' );
705
+    wpinv_get_template('invoice/company-address.php');
706 706
 }
707
-add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 );
707
+add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10);
708 708
 
709 709
 /**
710 710
  * Generates a watermark text for an invoice.
@@ -712,9 +712,9 @@  discard block
 block discarded – undo
712 712
  * @param WPInv_Invoice $invoice
713 713
  * @return string
714 714
  */
715
-function wpinv_watermark( $invoice ) {
716
-    $watermark = wpinv_get_watermark( $invoice );
717
-    return apply_filters( 'wpinv_get_watermark', $watermark, $invoice );
715
+function wpinv_watermark($invoice) {
716
+    $watermark = wpinv_get_watermark($invoice);
717
+    return apply_filters('wpinv_get_watermark', $watermark, $invoice);
718 718
 }
719 719
 
720 720
 /**
@@ -723,37 +723,37 @@  discard block
 block discarded – undo
723 723
  * @param WPInv_Invoice $invoice
724 724
  * @return string
725 725
  */
726
-function wpinv_get_watermark( $invoice ) {
726
+function wpinv_get_watermark($invoice) {
727 727
     return $invoice->get_status_nicename();
728 728
 }
729 729
 
730 730
 /**
731 731
  * @deprecated
732 732
  */
733
-function wpinv_display_invoice_details( $invoice ) {
734
-    return getpaid_invoice_meta( $invoice );
733
+function wpinv_display_invoice_details($invoice) {
734
+    return getpaid_invoice_meta($invoice);
735 735
 }
736 736
 
737 737
 /**
738 738
  * Displays invoice meta.
739 739
  */
740
-function getpaid_invoice_meta( $invoice ) {
740
+function getpaid_invoice_meta($invoice) {
741 741
 
742
-    $invoice = new WPInv_Invoice( $invoice );
742
+    $invoice = new WPInv_Invoice($invoice);
743 743
 
744 744
     // Ensure that we have an invoice.
745
-    if ( 0 == $invoice->get_id() ) {
745
+    if (0 == $invoice->get_id()) {
746 746
         return;
747 747
     }
748 748
 
749 749
     // Get the invoice meta.
750
-    $meta = getpaid_get_invoice_meta( $invoice );
750
+    $meta = getpaid_get_invoice_meta($invoice);
751 751
 
752 752
     // Display the meta.
753
-    wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) );
753
+    wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta'));
754 754
 
755 755
 }
756
-add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 );
756
+add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10);
757 757
 
758 758
 /**
759 759
  * Retrieves the address markup to use on Invoices.
@@ -765,29 +765,29 @@  discard block
 block discarded – undo
765 765
  * @param  string $separator How to separate address lines.
766 766
  * @return string
767 767
  */
768
-function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) {
768
+function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') {
769 769
 
770 770
     // Retrieve the address markup...
771
-    $country = empty( $billing_details['country'] ) ? '' : $billing_details['country'];
772
-    $format = wpinv_get_full_address_format( $country );
771
+    $country = empty($billing_details['country']) ? '' : $billing_details['country'];
772
+    $format = wpinv_get_full_address_format($country);
773 773
 
774 774
     // ... and the replacements.
775
-    $replacements = wpinv_get_invoice_address_replacements( $billing_details );
775
+    $replacements = wpinv_get_invoice_address_replacements($billing_details);
776 776
 
777
-    $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
777
+    $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format);
778 778
 
779 779
 	// Remove unavailable tags.
780
-    $formatted_address = preg_replace( '/\{\{\w+\}\}/', '', $formatted_address );
780
+    $formatted_address = preg_replace('/\{\{\w+\}\}/', '', $formatted_address);
781 781
 
782 782
     // Clean up white space.
783
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
784
-    $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
783
+	$formatted_address = preg_replace('/  +/', ' ', trim($formatted_address));
784
+    $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address);
785 785
 
786 786
     // Break newlines apart and remove empty lines/trim commas and white space.
787
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
787
+	$formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address)));
788 788
 
789 789
     // Add html breaks.
790
-	$formatted_address = implode( $separator, $formatted_address );
790
+	$formatted_address = implode($separator, $formatted_address);
791 791
 
792 792
 	// We're done!
793 793
 	return $formatted_address;
@@ -799,118 +799,118 @@  discard block
 block discarded – undo
799 799
  *
800 800
  * @param WPInv_Invoice $invoice
801 801
  */
802
-function wpinv_display_to_address( $invoice = 0 ) {
803
-    if ( ! empty( $invoice ) ) {
804
-        wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) );
802
+function wpinv_display_to_address($invoice = 0) {
803
+    if (!empty($invoice)) {
804
+        wpinv_get_template('invoice/billing-address.php', compact('invoice'));
805 805
     }
806 806
 }
807
-add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 );
807
+add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40);
808 808
 
809 809
 
810 810
 /**
811 811
  * Displays invoice line items.
812 812
  */
813
-function wpinv_display_line_items( $invoice_id = 0 ) {
813
+function wpinv_display_line_items($invoice_id = 0) {
814 814
 
815 815
     // Prepare the invoice.
816
-    $invoice = new WPInv_Invoice( $invoice_id );
816
+    $invoice = new WPInv_Invoice($invoice_id);
817 817
 
818 818
     // Abort if there is no invoice.
819
-    if ( 0 == $invoice->get_id() ) {
819
+    if (0 == $invoice->get_id()) {
820 820
         return;
821 821
     }
822 822
 
823 823
     // Line item columns.
824
-    $columns = getpaid_invoice_item_columns( $invoice );
825
-    $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice );
824
+    $columns = getpaid_invoice_item_columns($invoice);
825
+    $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice);
826 826
 
827
-    wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) );
827
+    wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns'));
828 828
 }
829
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 );
829
+add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10);
830 830
 
831 831
 /**
832 832
  * Displays invoice subscriptions.
833 833
  *
834 834
  * @param WPInv_Invoice $invoice
835 835
  */
836
-function getpaid_display_invoice_subscriptions( $invoice ) {
836
+function getpaid_display_invoice_subscriptions($invoice) {
837 837
 
838 838
     // Subscriptions.
839
-	$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
839
+	$subscriptions = getpaid_get_invoice_subscriptions($invoice);
840 840
 
841
-    if ( empty( $subscriptions ) || ! $invoice->is_recurring() ) {
841
+    if (empty($subscriptions) || !$invoice->is_recurring()) {
842 842
         return;
843 843
     }
844 844
 
845
-    $main_subscription = getpaid_get_invoice_subscription( $invoice );
845
+    $main_subscription = getpaid_get_invoice_subscription($invoice);
846 846
 
847 847
     // Display related subscriptions.
848
-    if ( is_array( $subscriptions ) ) {
849
-        printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Subscriptions', 'invoicing' ) );
850
-        getpaid_admin_subscription_related_subscriptions_metabox( $main_subscription, false );
848
+    if (is_array($subscriptions)) {
849
+        printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Subscriptions', 'invoicing'));
850
+        getpaid_admin_subscription_related_subscriptions_metabox($main_subscription, false);
851 851
     }
852 852
 
853
-    if ( $main_subscription->get_total_payments() > 1 ) {
854
-        printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Invoices', 'invoicing' ) );
855
-        getpaid_admin_subscription_invoice_details_metabox( $main_subscription, false );
853
+    if ($main_subscription->get_total_payments() > 1) {
854
+        printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Invoices', 'invoicing'));
855
+        getpaid_admin_subscription_invoice_details_metabox($main_subscription, false);
856 856
     }
857 857
 
858 858
 }
859
-add_action( 'getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55 );
860
-add_action( 'wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11 );
859
+add_action('getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55);
860
+add_action('wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11);
861 861
 
862 862
 /**
863 863
  * Displays invoice notices on invoices.
864 864
  */
865 865
 function wpinv_display_invoice_notice() {
866 866
 
867
-    $label  = wpinv_get_option( 'vat_invoice_notice_label' );
868
-    $notice = wpinv_get_option( 'vat_invoice_notice' );
867
+    $label  = wpinv_get_option('vat_invoice_notice_label');
868
+    $notice = wpinv_get_option('vat_invoice_notice');
869 869
 
870
-    if ( empty( $label ) && empty( $notice ) ) {
870
+    if (empty($label) && empty($notice)) {
871 871
         return;
872 872
     }
873 873
 
874 874
     echo '<div class="mt-4 mb-4 wpinv-vat-notice">';
875 875
 
876
-    if ( ! empty( $label ) ) {
877
-        echo "<h5>" . esc_html( $label ) . "</h5>";
876
+    if (!empty($label)) {
877
+        echo "<h5>" . esc_html($label) . "</h5>";
878 878
     }
879 879
 
880
-    if ( ! empty( $notice ) ) {
881
-        echo '<small class="form-text text-muted">' . wp_kses_post( wpautop( wptexturize( $notice ) ) ) . '</small>';
880
+    if (!empty($notice)) {
881
+        echo '<small class="form-text text-muted">' . wp_kses_post(wpautop(wptexturize($notice))) . '</small>';
882 882
     }
883 883
 
884 884
     echo '</div>';
885 885
 }
886
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 );
886
+add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100);
887 887
 
888 888
 /**
889 889
  * @param WPInv_Invoice $invoice
890 890
  */
891
-function wpinv_display_invoice_notes( $invoice ) {
891
+function wpinv_display_invoice_notes($invoice) {
892 892
 
893 893
     // Retrieve the notes.
894
-    $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' );
894
+    $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer');
895 895
 
896 896
     // Abort if we have non.
897
-    if ( empty( $notes ) ) {
897
+    if (empty($notes)) {
898 898
         return;
899 899
     }
900 900
 
901 901
     // Echo the note.
902 902
     echo '<div class="getpaid-invoice-notes-wrapper position-relative my-4">';
903
-    echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . esc_html__( 'Notes', 'invoicing' ) . '</h2>';
903
+    echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . esc_html__('Notes', 'invoicing') . '</h2>';
904 904
     echo '<ul class="getpaid-invoice-notes text-break overflow-auto list-unstyled p-0 m-0">';
905 905
 
906
-    foreach ( $notes as $note ) {
907
-        wpinv_get_invoice_note_line_item( $note );
906
+    foreach ($notes as $note) {
907
+        wpinv_get_invoice_note_line_item($note);
908 908
     }
909 909
 
910 910
     echo '</ul>';
911 911
     echo '</div>';
912 912
 }
913
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 );
913
+add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60);
914 914
 
915 915
 /**
916 916
  * Loads scripts on our invoice templates.
@@ -918,37 +918,37 @@  discard block
 block discarded – undo
918 918
 function wpinv_display_style() {
919 919
 
920 920
     // Make sure that all scripts have been loaded.
921
-    if ( ! did_action( 'wp_enqueue_scripts' ) ) {
922
-        do_action( 'wp_enqueue_scripts' );
921
+    if (!did_action('wp_enqueue_scripts')) {
922
+        do_action('wp_enqueue_scripts');
923 923
     }
924 924
 
925 925
     // Add global styles.
926
-    if ( wp_is_block_theme() ) {
927
-        wp_print_styles( 'global-styles' );
926
+    if (wp_is_block_theme()) {
927
+        wp_print_styles('global-styles');
928 928
     }
929 929
 
930 930
     // Register the invoices style.
931
-    wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) );
931
+    wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css'));
932 932
 
933 933
     // Load required styles
934
-    wp_print_styles( 'wpinv-single-style' );
935
-    wp_print_styles( 'ayecode-ui' );
934
+    wp_print_styles('wpinv-single-style');
935
+    wp_print_styles('ayecode-ui');
936 936
 
937 937
     // Maybe load custom css.
938
-    $custom_css = wpinv_get_option( 'template_custom_css' );
938
+    $custom_css = wpinv_get_option('template_custom_css');
939 939
 
940
-    if ( isset( $custom_css ) && ! empty( $custom_css ) ) {
941
-        $custom_css     = wp_kses( $custom_css, array( '\'', '\"' ) );
942
-        $custom_css     = str_replace( '&gt;', '>', $custom_css );
940
+    if (isset($custom_css) && !empty($custom_css)) {
941
+        $custom_css     = wp_kses($custom_css, array('\'', '\"'));
942
+        $custom_css     = str_replace('&gt;', '>', $custom_css);
943 943
         echo '<style type="text/css">';
944
-        echo wp_kses_post( $custom_css );
944
+        echo wp_kses_post($custom_css);
945 945
         echo '</style>';
946 946
     }
947 947
 
948 948
     wp_site_icon();
949 949
 }
950
-add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' );
951
-add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' );
950
+add_action('wpinv_invoice_print_head', 'wpinv_display_style');
951
+add_action('wpinv_invalid_invoice_head', 'wpinv_display_style');
952 952
 
953 953
 
954 954
 /**
@@ -960,41 +960,41 @@  discard block
 block discarded – undo
960 960
     // Retrieve the current invoice.
961 961
     $invoice_id = getpaid_get_current_invoice_id();
962 962
 
963
-    if ( empty( $invoice_id ) ) {
963
+    if (empty($invoice_id)) {
964 964
 
965 965
         return aui()->alert(
966 966
             array(
967 967
                 'type'    => 'warning',
968
-                'content' => __( 'Invalid invoice', 'invoicing' ),
968
+                'content' => __('Invalid invoice', 'invoicing'),
969 969
             )
970 970
         );
971 971
 
972 972
     }
973 973
 
974 974
     // Can the user view this invoice?
975
-    if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) {
975
+    if (!wpinv_user_can_view_invoice($invoice_id)) {
976 976
 
977 977
         return aui()->alert(
978 978
             array(
979 979
                 'type'    => 'warning',
980
-                'content' => __( 'You are not allowed to view this invoice', 'invoicing' ),
980
+                'content' => __('You are not allowed to view this invoice', 'invoicing'),
981 981
             )
982 982
         );
983 983
 
984 984
     }
985 985
 
986 986
     // Ensure that it is not yet paid for.
987
-    $invoice = new WPInv_Invoice( $invoice_id );
987
+    $invoice = new WPInv_Invoice($invoice_id);
988 988
 
989 989
     // Maybe mark it as viewed.
990
-    getpaid_maybe_mark_invoice_as_viewed( $invoice );
990
+    getpaid_maybe_mark_invoice_as_viewed($invoice);
991 991
 
992
-    if ( $invoice->is_paid() ) {
992
+    if ($invoice->is_paid()) {
993 993
 
994 994
         return aui()->alert(
995 995
             array(
996 996
                 'type'    => 'success',
997
-                'content' => __( 'This invoice has already been paid.', 'invoicing' ),
997
+                'content' => __('This invoice has already been paid.', 'invoicing'),
998 998
             )
999 999
         );
1000 1000
 
@@ -1004,15 +1004,15 @@  discard block
 block discarded – undo
1004 1004
     $wpi_checkout_id = $invoice_id;
1005 1005
 
1006 1006
     // Retrieve appropriate payment form.
1007
-    $payment_form = new GetPaid_Payment_Form( wpinv_translate_post_id( $invoice->get_meta( 'force_payment_form' ) ) );
1008
-    $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1007
+    $payment_form = new GetPaid_Payment_Form(wpinv_translate_post_id($invoice->get_meta('force_payment_form')));
1008
+    $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1009 1009
 
1010
-    if ( ! $payment_form->exists() ) {
1010
+    if (!$payment_form->exists()) {
1011 1011
 
1012 1012
         return aui()->alert(
1013 1013
             array(
1014 1014
                 'type'    => 'warning',
1015
-                'content' => __( 'Error loading the payment form', 'invoicing' ),
1015
+                'content' => __('Error loading the payment form', 'invoicing'),
1016 1016
             )
1017 1017
         );
1018 1018
 
@@ -1021,29 +1021,29 @@  discard block
 block discarded – undo
1021 1021
     // Set the invoice.
1022 1022
     $payment_form->invoice = $invoice;
1023 1023
 
1024
-    if ( ! $payment_form->is_default() ) {
1024
+    if (!$payment_form->is_default()) {
1025 1025
 
1026 1026
         $items    = array();
1027 1027
         $item_ids = array();
1028 1028
 
1029
-        foreach ( $invoice->get_items() as $item ) {
1030
-            if ( ! in_array( $item->get_id(), $item_ids ) ) {
1029
+        foreach ($invoice->get_items() as $item) {
1030
+            if (!in_array($item->get_id(), $item_ids)) {
1031 1031
                 $item_ids[] = $item->get_id();
1032 1032
                 $items[]    = $item;
1033 1033
             }
1034 1034
         }
1035 1035
 
1036
-        foreach ( $payment_form->get_items() as $item ) {
1037
-            if ( ! in_array( $item->get_id(), $item_ids ) ) {
1036
+        foreach ($payment_form->get_items() as $item) {
1037
+            if (!in_array($item->get_id(), $item_ids)) {
1038 1038
                 $item_ids[] = $item->get_id();
1039 1039
                 $items[]    = $item;
1040 1040
             }
1041 1041
         }
1042 1042
 
1043
-        $payment_form->set_items( $items );
1043
+        $payment_form->set_items($items);
1044 1044
 
1045 1045
     } else {
1046
-        $payment_form->set_items( $invoice->get_items() );
1046
+        $payment_form->set_items($invoice->get_items());
1047 1047
     }
1048 1048
 
1049 1049
     // Generate the html.
@@ -1052,7 +1052,7 @@  discard block
 block discarded – undo
1052 1052
 }
1053 1053
 
1054 1054
 function wpinv_empty_cart_message() {
1055
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1055
+	return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>');
1056 1056
 }
1057 1057
 
1058 1058
 /**
@@ -1070,76 +1070,76 @@  discard block
 block discarded – undo
1070 1070
         true
1071 1071
     );
1072 1072
 }
1073
-add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' );
1073
+add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart');
1074 1074
 
1075 1075
 /**
1076 1076
  * Filters the receipt page.
1077 1077
  */
1078
-function wpinv_filter_success_page_content( $content ) {
1078
+function wpinv_filter_success_page_content($content) {
1079 1079
 
1080 1080
     // Maybe abort early.
1081
-    if ( is_admin() || ! is_singular() || ! in_the_loop() || ! is_main_query() || is_preview() ) {
1081
+    if (is_admin() || !is_singular() || !in_the_loop() || !is_main_query() || is_preview()) {
1082 1082
         return $content;
1083 1083
     }
1084 1084
 
1085 1085
     // Ensure this is our page.
1086
-    if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) {
1086
+    if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) {
1087 1087
 
1088
-        $gateway = sanitize_text_field( $_GET['payment-confirm'] );
1089
-        return apply_filters( "wpinv_payment_confirm_$gateway", $content );
1088
+        $gateway = sanitize_text_field($_GET['payment-confirm']);
1089
+        return apply_filters("wpinv_payment_confirm_$gateway", $content);
1090 1090
 
1091 1091
     }
1092 1092
 
1093 1093
     return $content;
1094 1094
 }
1095
-add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 );
1095
+add_filter('the_content', 'wpinv_filter_success_page_content', 99999);
1096 1096
 
1097
-function wpinv_invoice_link( $invoice_id ) {
1098
-    $invoice = wpinv_get_invoice( $invoice_id );
1097
+function wpinv_invoice_link($invoice_id) {
1098
+    $invoice = wpinv_get_invoice($invoice_id);
1099 1099
 
1100
-    if ( empty( $invoice ) ) {
1100
+    if (empty($invoice)) {
1101 1101
         return null;
1102 1102
     }
1103 1103
 
1104
-    $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>';
1104
+    $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>';
1105 1105
 
1106
-    return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice );
1106
+    return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice);
1107 1107
 }
1108 1108
 
1109
-function wpinv_get_invoice_note_line_item( $note, $echo = true ) {
1110
-    if ( empty( $note ) ) {
1109
+function wpinv_get_invoice_note_line_item($note, $echo = true) {
1110
+    if (empty($note)) {
1111 1111
         return null;
1112 1112
     }
1113 1113
 
1114
-    if ( is_int( $note ) ) {
1115
-        $note = get_comment( $note );
1114
+    if (is_int($note)) {
1115
+        $note = get_comment($note);
1116 1116
     }
1117 1117
 
1118
-    if ( ! ( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) {
1118
+    if (!(is_object($note) && is_a($note, 'WP_Comment'))) {
1119 1119
         return null;
1120 1120
     }
1121 1121
 
1122
-    $note_classes   = array( 'note' );
1123
-    $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : '';
1122
+    $note_classes   = array('note');
1123
+    $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : '';
1124 1124
     $note_classes[] = $note->comment_author === 'System' ? 'system-note' : '';
1125
-    $note_classes   = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note );
1126
-    $note_classes   = ! empty( $note_classes ) ? implode( ' ', $note_classes ) : '';
1125
+    $note_classes   = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note);
1126
+    $note_classes   = !empty($note_classes) ? implode(' ', $note_classes) : '';
1127 1127
 
1128 1128
     ob_start();
1129 1129
     ?>
1130
-    <li rel="<?php echo absint( $note->comment_ID ); ?>" class="<?php echo esc_attr( $note_classes ); ?> mb-2">
1130
+    <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mb-2">
1131 1131
         <div class="note_content">
1132 1132
 
1133
-            <?php echo wp_kses_post( wptexturize( $note->comment_content ) ); ?>
1133
+            <?php echo wp_kses_post(wptexturize($note->comment_content)); ?>
1134 1134
 
1135
-            <?php if ( ! is_admin() ) : ?>
1135
+            <?php if (!is_admin()) : ?>
1136 1136
                 <em class="small form-text text-muted mt-0">
1137 1137
                     <?php
1138 1138
                         printf(
1139
-                            esc_html__( '%1$s - %2$s at %3$s', 'invoicing' ),
1140
-                            esc_html( $note->comment_author ),
1141
-                            esc_html( getpaid_format_date_value( $note->comment_date ) ),
1142
-                            esc_html( date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) )
1139
+                            esc_html__('%1$s - %2$s at %3$s', 'invoicing'),
1140
+                            esc_html($note->comment_author),
1141
+                            esc_html(getpaid_format_date_value($note->comment_date)),
1142
+                            esc_html(date_i18n(get_option('time_format'), strtotime($note->comment_date)))
1143 1143
                         );
1144 1144
                     ?>
1145 1145
                 </em>
@@ -1147,21 +1147,21 @@  discard block
 block discarded – undo
1147 1147
 
1148 1148
         </div>
1149 1149
 
1150
-        <?php if ( is_admin() ) : ?>
1150
+        <?php if (is_admin()) : ?>
1151 1151
 
1152 1152
             <p class="meta px-4 py-2">
1153
-                <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>">
1153
+                <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>">
1154 1154
                     <?php
1155 1155
                         printf(
1156
-                            esc_html__( '%1$s - %2$s at %3$s', 'invoicing' ),
1157
-                            esc_html( $note->comment_author ),
1158
-                            esc_html( getpaid_format_date_value( $note->comment_date ) ),
1159
-                            esc_html( date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) )
1156
+                            esc_html__('%1$s - %2$s at %3$s', 'invoicing'),
1157
+                            esc_html($note->comment_author),
1158
+                            esc_html(getpaid_format_date_value($note->comment_date)),
1159
+                            esc_html(date_i18n(get_option('time_format'), strtotime($note->comment_date)))
1160 1160
                         );
1161 1161
                     ?>
1162 1162
                 </abbr>&nbsp;&nbsp;
1163
-                <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?>
1164
-                    <a href="#" class="delete_note" data-id="<?php echo esc_attr( $note->comment_ID ); ?>"><?php esc_html_e( 'Delete note', 'invoicing' ); ?></a>
1163
+                <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?>
1164
+                    <a href="#" class="delete_note" data-id="<?php echo esc_attr($note->comment_ID); ?>"><?php esc_html_e('Delete note', 'invoicing'); ?></a>
1165 1165
                 <?php } ?>
1166 1166
             </p>
1167 1167
 
@@ -1170,10 +1170,10 @@  discard block
 block discarded – undo
1170 1170
     </li>
1171 1171
     <?php
1172 1172
     $note_content = ob_get_clean();
1173
-    $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo );
1173
+    $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo);
1174 1174
 
1175
-    if ( $echo ) {
1176
-        echo wp_kses_post( $note_content );
1175
+    if ($echo) {
1176
+        echo wp_kses_post($note_content);
1177 1177
     } else {
1178 1178
         return $note_content;
1179 1179
     }
@@ -1186,43 +1186,43 @@  discard block
 block discarded – undo
1186 1186
  * @return string
1187 1187
  */
1188 1188
 function wpinv_get_policy_text() {
1189
-    $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 );
1189
+    $privacy_page_id = get_option('wp_page_for_privacy_policy', 0);
1190 1190
 
1191
-    $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]' ) );
1191
+    $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]'));
1192 1192
 
1193
-    if ( ! $privacy_page_id ) {
1194
-        $privacy_page_id = wpinv_get_option( 'privacy_page', 0 );
1193
+    if (!$privacy_page_id) {
1194
+        $privacy_page_id = wpinv_get_option('privacy_page', 0);
1195 1195
     }
1196 1196
 
1197
-    $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' );
1197
+    $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');
1198 1198
 
1199 1199
     $find_replace = array(
1200 1200
         '[wpinv_privacy_policy]' => $privacy_link,
1201 1201
     );
1202 1202
 
1203
-    $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text );
1203
+    $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text);
1204 1204
 
1205
-    return wp_kses_post( wpautop( $privacy_text ) );
1205
+    return wp_kses_post(wpautop($privacy_text));
1206 1206
 }
1207 1207
 
1208 1208
 function wpinv_oxygen_fix_conflict() {
1209 1209
     global $ct_ignore_post_types;
1210 1210
 
1211
-    if ( ! is_array( $ct_ignore_post_types ) ) {
1211
+    if (!is_array($ct_ignore_post_types)) {
1212 1212
         $ct_ignore_post_types = array();
1213 1213
     }
1214 1214
 
1215
-    $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form' );
1215
+    $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form');
1216 1216
 
1217
-    foreach ( $post_types as $post_type ) {
1217
+    foreach ($post_types as $post_type) {
1218 1218
         $ct_ignore_post_types[] = $post_type;
1219 1219
 
1220 1220
         // Ignore post type
1221
-        add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 );
1221
+        add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999);
1222 1222
     }
1223 1223
 
1224
-    remove_filter( 'template_include', 'wpinv_template', 10, 1 );
1225
-    add_filter( 'template_include', 'wpinv_template', 999, 1 );
1224
+    remove_filter('template_include', 'wpinv_template', 10, 1);
1225
+    add_filter('template_include', 'wpinv_template', 999, 1);
1226 1226
 }
1227 1227
 
1228 1228
 /**
@@ -1230,10 +1230,10 @@  discard block
 block discarded – undo
1230 1230
  *
1231 1231
  * @param GetPaid_Payment_Form $form
1232 1232
  */
1233
-function getpaid_display_payment_form( $form ) {
1233
+function getpaid_display_payment_form($form) {
1234 1234
 
1235
-    if ( is_numeric( $form ) ) {
1236
-        $form = new GetPaid_Payment_Form( wpinv_translate_post_id( $form ) );
1235
+    if (is_numeric($form)) {
1236
+        $form = new GetPaid_Payment_Form(wpinv_translate_post_id($form));
1237 1237
     }
1238 1238
 
1239 1239
     $form->display();
@@ -1243,61 +1243,61 @@  discard block
 block discarded – undo
1243 1243
 /**
1244 1244
  * Helper function to display a item payment form on the frontend.
1245 1245
  */
1246
-function getpaid_display_item_payment_form( $items ) {
1246
+function getpaid_display_item_payment_form($items) {
1247 1247
 
1248
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1249
-    $form->set_items( $items );
1248
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1249
+    $form->set_items($items);
1250 1250
 
1251
-    if ( 0 == count( $form->get_items() ) ) {
1251
+    if (0 == count($form->get_items())) {
1252 1252
         aui()->alert(
1253 1253
 			array(
1254 1254
 				'type'    => 'warning',
1255
-				'content' => __( 'No published items found', 'invoicing' ),
1255
+				'content' => __('No published items found', 'invoicing'),
1256 1256
             ),
1257 1257
             true
1258 1258
         );
1259 1259
         return;
1260 1260
     }
1261 1261
 
1262
-    $extra_items     = esc_attr( getpaid_convert_items_to_string( $items ) );
1263
-    $extra_items_key = md5( NONCE_KEY . AUTH_KEY . $extra_items );
1262
+    $extra_items     = esc_attr(getpaid_convert_items_to_string($items));
1263
+    $extra_items_key = md5(NONCE_KEY . AUTH_KEY . $extra_items);
1264 1264
     $extra_items     = "<input type='hidden' name='getpaid-form-items' value='$extra_items' />";
1265 1265
     $extra_items    .= "<input type='hidden' name='getpaid-form-items-key' value='$extra_items_key' />";
1266 1266
 
1267
-    $form->display( $extra_items );
1267
+    $form->display($extra_items);
1268 1268
 }
1269 1269
 
1270 1270
 /**
1271 1271
  * Helper function to display an invoice payment form on the frontend.
1272 1272
  */
1273
-function getpaid_display_invoice_payment_form( $invoice_id ) {
1273
+function getpaid_display_invoice_payment_form($invoice_id) {
1274 1274
 
1275
-    $invoice = wpinv_get_invoice( $invoice_id );
1275
+    $invoice = wpinv_get_invoice($invoice_id);
1276 1276
 
1277
-    if ( empty( $invoice ) ) {
1277
+    if (empty($invoice)) {
1278 1278
 		aui()->alert(
1279 1279
 			array(
1280 1280
 				'type'    => 'warning',
1281
-				'content' => __( 'Invoice not found', 'invoicing' ),
1281
+				'content' => __('Invoice not found', 'invoicing'),
1282 1282
             ),
1283 1283
             true
1284 1284
         );
1285 1285
         return;
1286 1286
     }
1287 1287
 
1288
-    if ( $invoice->is_paid() ) {
1288
+    if ($invoice->is_paid()) {
1289 1289
 		aui()->alert(
1290 1290
 			array(
1291 1291
 				'type'    => 'warning',
1292
-				'content' => __( 'Invoice has already been paid', 'invoicing' ),
1292
+				'content' => __('Invoice has already been paid', 'invoicing'),
1293 1293
             ),
1294 1294
             true
1295 1295
         );
1296 1296
         return;
1297 1297
     }
1298 1298
 
1299
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1300
-    $form->set_items( $invoice->get_items() );
1299
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1300
+    $form->set_items($invoice->get_items());
1301 1301
 
1302 1302
     $form->display();
1303 1303
 }
@@ -1305,24 +1305,24 @@  discard block
 block discarded – undo
1305 1305
 /**
1306 1306
  * Helper function to convert item string to array.
1307 1307
  */
1308
-function getpaid_convert_items_to_array( $items ) {
1309
-    $items    = array_filter( array_map( 'trim', explode( ',', $items ) ) );
1308
+function getpaid_convert_items_to_array($items) {
1309
+    $items    = array_filter(array_map('trim', explode(',', $items)));
1310 1310
     $prepared = array();
1311 1311
 
1312
-    foreach ( $items as $item ) {
1313
-        $data = array_map( 'trim', explode( '|', $item ) );
1312
+    foreach ($items as $item) {
1313
+        $data = array_map('trim', explode('|', $item));
1314 1314
 
1315
-        if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) {
1315
+        if (empty($data[0]) || !is_numeric($data[0])) {
1316 1316
             continue;
1317 1317
         }
1318 1318
 
1319 1319
         $quantity = 1;
1320
-        if ( isset( $data[1] ) && is_numeric( $data[1] ) ) {
1320
+        if (isset($data[1]) && is_numeric($data[1])) {
1321 1321
             $quantity = (float) $data[1];
1322 1322
         }
1323 1323
 
1324 1324
         // WPML support.
1325
-        $prepared[ wpinv_translate_post_id( $data[0] ) ] = $quantity;
1325
+        $prepared[wpinv_translate_post_id($data[0])] = $quantity;
1326 1326
 
1327 1327
     }
1328 1328
 
@@ -1332,13 +1332,13 @@  discard block
 block discarded – undo
1332 1332
 /**
1333 1333
  * Helper function to convert item array to string.
1334 1334
  */
1335
-function getpaid_convert_items_to_string( $items ) {
1335
+function getpaid_convert_items_to_string($items) {
1336 1336
     $prepared = array();
1337 1337
 
1338
-    foreach ( $items as $item => $quantity ) {
1338
+    foreach ($items as $item => $quantity) {
1339 1339
         $prepared[] = "$item|$quantity";
1340 1340
     }
1341
-    return implode( ',', $prepared );
1341
+    return implode(',', $prepared);
1342 1342
 }
1343 1343
 
1344 1344
 /**
@@ -1346,21 +1346,21 @@  discard block
 block discarded – undo
1346 1346
  *
1347 1347
  * Provide a label and one of $form, $items or $invoice.
1348 1348
  */
1349
-function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) {
1350
-    $label = sanitize_text_field( $label );
1349
+function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) {
1350
+    $label = sanitize_text_field($label);
1351 1351
 
1352
-    if ( ! empty( $form ) ) {
1353
-        $form  = esc_attr( $form );
1352
+    if (!empty($form)) {
1353
+        $form = esc_attr($form);
1354 1354
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>";
1355 1355
     }
1356 1356
 
1357
-	if ( ! empty( $items ) ) {
1358
-        $items  = esc_attr( $items );
1357
+	if (!empty($items)) {
1358
+        $items = esc_attr($items);
1359 1359
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>";
1360 1360
     }
1361 1361
 
1362
-    if ( ! empty( $invoice ) ) {
1363
-        $invoice  = esc_attr( $invoice );
1362
+    if (!empty($invoice)) {
1363
+        $invoice = esc_attr($invoice);
1364 1364
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-invoice='$invoice'>$label</button>";
1365 1365
     }
1366 1366
 
@@ -1371,17 +1371,17 @@  discard block
 block discarded – undo
1371 1371
  *
1372 1372
  * @param WPInv_Invoice $invoice
1373 1373
  */
1374
-function getpaid_the_invoice_description( $invoice ) {
1374
+function getpaid_the_invoice_description($invoice) {
1375 1375
     $description = $invoice->get_description();
1376 1376
 
1377
-    if ( empty( $description ) ) {
1377
+    if (empty($description)) {
1378 1378
         return;
1379 1379
     }
1380 1380
 
1381
-    echo "<small class='getpaid-invoice-description text-dark pl-2 ps-2 form-text' style='margin-bottom:20px;border-left:2px solid #2196F3;display:block;padding-left:.5rem'><em>" . wp_kses_post( wpautop( $description ) ) . "</em></small>";
1381
+    echo "<small class='getpaid-invoice-description text-dark pl-2 ps-2 form-text' style='margin-bottom:20px;border-left:2px solid #2196F3;display:block;padding-left:.5rem'><em>" . wp_kses_post(wpautop($description)) . "</em></small>";
1382 1382
 }
1383
-add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 );
1384
-add_action( 'wpinv_email_billing_details', 'getpaid_the_invoice_description', 100 );
1383
+add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100);
1384
+add_action('wpinv_email_billing_details', 'getpaid_the_invoice_description', 100);
1385 1385
 
1386 1386
 /**
1387 1387
  * Render element on a form.
@@ -1389,86 +1389,86 @@  discard block
 block discarded – undo
1389 1389
  * @param array $element
1390 1390
  * @param GetPaid_Payment_Form $form
1391 1391
  */
1392
-function getpaid_payment_form_element( $element, $form ) {
1393
-    $translatable = array( 'text', 'label', 'input_label', 'button_label', 'description' );
1392
+function getpaid_payment_form_element($element, $form) {
1393
+    $translatable = array('text', 'label', 'input_label', 'button_label', 'description');
1394 1394
 
1395
-    foreach ( $translatable as $string ) {
1396
-        if ( ! empty( $element[ $string ] ) && is_scalar( $element[ $string ] ) ) {
1397
-            $element[ $string ] = __( $element[ $string ], 'invoicing' );
1395
+    foreach ($translatable as $string) {
1396
+        if (!empty($element[$string]) && is_scalar($element[$string])) {
1397
+            $element[$string] = __($element[$string], 'invoicing');
1398 1398
         }
1399 1399
     }
1400 1400
 
1401 1401
     // Set up the args.
1402
-    $element_type    = trim( $element['type'] );
1402
+    $element_type    = trim($element['type']);
1403 1403
     $element['form'] = $form;
1404
-    extract( $element ); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
1404
+    extract($element); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
1405 1405
 
1406 1406
     // Try to locate the appropriate template.
1407
-    $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" );
1407
+    $located = wpinv_locate_template("payment-forms/elements/$element_type.php");
1408 1408
 
1409 1409
     // Abort if this is not our element.
1410
-    if ( empty( $located ) || ! file_exists( $located ) ) {
1410
+    if (empty($located) || !file_exists($located)) {
1411 1411
         return;
1412 1412
     }
1413 1413
 
1414 1414
     // Generate the class and id of the element.
1415
-    $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) );
1416
-    $id            = isset( $id ) ? $id : uniqid( 'gp' );
1415
+    $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type));
1416
+    $id            = isset($id) ? $id : uniqid('gp');
1417 1417
 
1418
-    $element_id    = ! empty( $element['label'] ) ? sanitize_title( $element['label'] ) : $id;
1419
-    $query_value   = isset( $_GET[ $element_id ] ) ? wpinv_clean( urldecode_deep( $_GET[ $element_id ] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
1418
+    $element_id    = !empty($element['label']) ? sanitize_title($element['label']) : $id;
1419
+    $query_value   = isset($_GET[$element_id]) ? wpinv_clean(urldecode_deep($_GET[$element_id])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
1420 1420
 
1421 1421
     $element_id    = 'getpaid-' . $element_id;
1422
-    if ( ! empty( $GLOBALS['rendered_getpaid_forms'][ $form->get_id() ] ) ) {
1423
-        $element_id = $element_id . '-' . $GLOBALS['rendered_getpaid_forms'][ $form->get_id() ];
1422
+    if (!empty($GLOBALS['rendered_getpaid_forms'][$form->get_id()])) {
1423
+        $element_id = $element_id . '-' . $GLOBALS['rendered_getpaid_forms'][$form->get_id()];
1424 1424
     }
1425 1425
 
1426 1426
     // Echo the opening wrapper.
1427
-    echo "<div class='getpaid-payment-form-element " . esc_attr( $wrapper_class ) . "'>";
1427
+    echo "<div class='getpaid-payment-form-element " . esc_attr($wrapper_class) . "'>";
1428 1428
 
1429 1429
     // Fires before displaying a given element type's content.
1430
-    do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form );
1430
+    do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form);
1431 1431
 
1432 1432
     // Include the template for the element.
1433 1433
     include $located;
1434 1434
 
1435 1435
     // Fires after displaying a given element type's content.
1436
-    do_action( "getpaid_payment_form_{$element_type}_element", $element, $form );
1436
+    do_action("getpaid_payment_form_{$element_type}_element", $element, $form);
1437 1437
 
1438 1438
     // Echo the closing wrapper.
1439 1439
     echo '</div>';
1440 1440
 }
1441
-add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 );
1441
+add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2);
1442 1442
 
1443 1443
 /**
1444 1444
  * Render an element's edit page.
1445 1445
  *
1446 1446
  * @param WP_Post $post
1447 1447
  */
1448
-function getpaid_payment_form_edit_element_template( $post ) {
1448
+function getpaid_payment_form_edit_element_template($post) {
1449 1449
 
1450 1450
     // Retrieve all elements.
1451
-    $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' );
1451
+    $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type');
1452 1452
 
1453
-    foreach ( $all_elements as $element ) {
1453
+    foreach ($all_elements as $element) {
1454 1454
 
1455 1455
         // Try to locate the appropriate template.
1456
-        $element = esc_attr( sanitize_key( $element ) );
1457
-        $located = wpinv_locate_template( "payment-forms-admin/edit/$element.php" );
1456
+        $element = esc_attr(sanitize_key($element));
1457
+        $located = wpinv_locate_template("payment-forms-admin/edit/$element.php");
1458 1458
 
1459 1459
         // Continue if this is not our element.
1460
-        if ( empty( $located ) || ! file_exists( $located ) ) {
1460
+        if (empty($located) || !file_exists($located)) {
1461 1461
             continue;
1462 1462
         }
1463 1463
 
1464 1464
         // Include the template for the element.
1465
-        echo "<div v-if=\"active_form_element.type=='" . esc_attr( $element ) . "'\">";
1465
+        echo "<div v-if=\"active_form_element.type=='" . esc_attr($element) . "'\">";
1466 1466
         include $located;
1467 1467
         echo '</div>';
1468 1468
     }
1469 1469
 
1470 1470
 }
1471
-add_action( 'getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template' );
1471
+add_action('getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template');
1472 1472
 
1473 1473
 /**
1474 1474
  * Render an element's preview.
@@ -1477,27 +1477,27 @@  discard block
 block discarded – undo
1477 1477
 function getpaid_payment_form_render_element_preview_template() {
1478 1478
 
1479 1479
     // Retrieve all elements.
1480
-    $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' );
1480
+    $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type');
1481 1481
 
1482
-    foreach ( $all_elements as $element ) {
1482
+    foreach ($all_elements as $element) {
1483 1483
 
1484 1484
         // Try to locate the appropriate template.
1485
-        $element = sanitize_key( $element );
1486
-        $located = wpinv_locate_template( "payment-forms-admin/previews/$element.php" );
1485
+        $element = sanitize_key($element);
1486
+        $located = wpinv_locate_template("payment-forms-admin/previews/$element.php");
1487 1487
 
1488 1488
         // Continue if this is not our element.
1489
-        if ( empty( $located ) || ! file_exists( $located ) ) {
1489
+        if (empty($located) || !file_exists($located)) {
1490 1490
             continue;
1491 1491
         }
1492 1492
 
1493 1493
         // Include the template for the element.
1494
-        echo "<div v-if=\"form_element.type=='" . esc_html( $element ) . "'\">";
1494
+        echo "<div v-if=\"form_element.type=='" . esc_html($element) . "'\">";
1495 1495
         include $located;
1496 1496
         echo '</div>';
1497 1497
     }
1498 1498
 
1499 1499
 }
1500
-add_action( 'wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template' );
1500
+add_action('wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template');
1501 1501
 
1502 1502
 /**
1503 1503
  * Shows a list of gateways that support recurring payments.
@@ -1505,17 +1505,17 @@  discard block
 block discarded – undo
1505 1505
 function wpinv_get_recurring_gateways_text() {
1506 1506
     $gateways = array();
1507 1507
 
1508
-    foreach ( wpinv_get_payment_gateways() as $key => $gateway ) {
1509
-        if ( wpinv_gateway_support_subscription( $key ) ) {
1510
-            $gateways[] = sanitize_text_field( $gateway['admin_label'] );
1508
+    foreach (wpinv_get_payment_gateways() as $key => $gateway) {
1509
+        if (wpinv_gateway_support_subscription($key)) {
1510
+            $gateways[] = sanitize_text_field($gateway['admin_label']);
1511 1511
         }
1512 1512
     }
1513 1513
 
1514
-    if ( empty( $gateways ) ) {
1515
-        return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) . '</span>';
1514
+    if (empty($gateways)) {
1515
+        return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . '</span>';
1516 1516
     }
1517 1517
 
1518
-    return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) . '</span>';
1518
+    return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . '</span>';
1519 1519
 
1520 1520
 }
1521 1521
 
@@ -1525,7 +1525,7 @@  discard block
 block discarded – undo
1525 1525
  * @return GetPaid_Template
1526 1526
  */
1527 1527
 function getpaid_template() {
1528
-    return getpaid()->get( 'template' );
1528
+    return getpaid()->get('template');
1529 1529
 }
1530 1530
 
1531 1531
 /**
@@ -1534,8 +1534,8 @@  discard block
 block discarded – undo
1534 1534
  * @param array args
1535 1535
  * @return string
1536 1536
  */
1537
-function getpaid_paginate_links( $args ) {
1538
-    return str_replace( 'page-link dots', 'page-link text-dark', aui()->pagination( $args ) );
1537
+function getpaid_paginate_links($args) {
1538
+    return str_replace('page-link dots', 'page-link text-dark', aui()->pagination($args));
1539 1539
 }
1540 1540
 
1541 1541
 /**
@@ -1545,22 +1545,22 @@  discard block
 block discarded – undo
1545 1545
  * @param string state
1546 1546
  * @return string
1547 1547
  */
1548
-function getpaid_get_states_select_markup( $country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state', $echo = false ) {
1548
+function getpaid_get_states_select_markup($country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state', $echo = false) {
1549 1549
 
1550
-    $states = wpinv_get_country_states( $country );
1551
-    $uniqid = uniqid( '_' );
1550
+    $states = wpinv_get_country_states($country);
1551
+    $uniqid = uniqid('_');
1552 1552
 
1553
-    if ( ! empty( $states ) ) {
1553
+    if (!empty($states)) {
1554 1554
 
1555 1555
         return aui()->select(
1556 1556
             array(
1557 1557
 				'options'          => $states,
1558
-				'name'             => esc_attr( $field_name ),
1559
-				'id'               => sanitize_html_class( $field_name ) . $uniqid,
1560
-				'value'            => sanitize_text_field( $state ),
1558
+				'name'             => esc_attr($field_name),
1559
+				'id'               => sanitize_html_class($field_name) . $uniqid,
1560
+				'value'            => sanitize_text_field($state),
1561 1561
 				'placeholder'      => $placeholder,
1562 1562
 				'required'         => $required,
1563
-				'label'            => wp_kses_post( $label ),
1563
+				'label'            => wp_kses_post($label),
1564 1564
 				'label_type'       => 'vertical',
1565 1565
 				'help_text'        => $help_text,
1566 1566
 				'class'            => 'getpaid-address-field wpinv_state',
@@ -1577,14 +1577,14 @@  discard block
 block discarded – undo
1577 1577
 
1578 1578
     return aui()->input(
1579 1579
         array(
1580
-            'name'             => esc_attr( $field_name ),
1581
-            'id'               => sanitize_html_class( $field_name ) . $uniqid,
1580
+            'name'             => esc_attr($field_name),
1581
+            'id'               => sanitize_html_class($field_name) . $uniqid,
1582 1582
             'placeholder'      => $placeholder,
1583 1583
             'required'         => $required,
1584
-            'label'            => wp_kses_post( $label ),
1584
+            'label'            => wp_kses_post($label),
1585 1585
             'label_type'       => 'vertical',
1586 1586
             'help_text'        => $help_text,
1587
-            'value'            => sanitize_text_field( $state ),
1587
+            'value'            => sanitize_text_field($state),
1588 1588
             'class'            => 'getpaid-address-field wpinv_state',
1589 1589
             'wrap_class'       => "$wrapper_class getpaid-address-field-wrapper__state",
1590 1590
             'label_class'      => 'getpaid-address-field-label getpaid-address-field-label__state',
@@ -1603,16 +1603,16 @@  discard block
 block discarded – undo
1603 1603
  * @param array $element
1604 1604
  * @return string
1605 1605
  */
1606
-function getpaid_get_form_element_grid_class( $element ) {
1606
+function getpaid_get_form_element_grid_class($element) {
1607 1607
 
1608 1608
     $class = 'col-12';
1609
-    $width = empty( $element['grid_width'] ) ? 'full' : $element['grid_width'];
1609
+    $width = empty($element['grid_width']) ? 'full' : $element['grid_width'];
1610 1610
 
1611
-    if ( $width == 'half' ) {
1611
+    if ($width == 'half') {
1612 1612
         $class .= ' col-md-6';
1613 1613
     }
1614 1614
 
1615
-    if ( $width == 'third' ) {
1615
+    if ($width == 'third') {
1616 1616
         $class .= ' col-md-4';
1617 1617
     }
1618 1618
 
@@ -1627,15 +1627,15 @@  discard block
 block discarded – undo
1627 1627
  *
1628 1628
  * @return string
1629 1629
  */
1630
-function getpaid_embed_url( $payment_form = false, $items = false ) {
1630
+function getpaid_embed_url($payment_form = false, $items = false) {
1631 1631
 
1632 1632
     return add_query_arg(
1633 1633
         array(
1634 1634
             'getpaid_embed' => 1,
1635
-            'form'          => $payment_form ? absint( $payment_form ) : false,
1636
-            'item'          => $items ? urlencode( $items ) : false,
1635
+            'form'          => $payment_form ? absint($payment_form) : false,
1636
+            'item'          => $items ? urlencode($items) : false,
1637 1637
         ),
1638
-        home_url( 'index.php' )
1638
+        home_url('index.php')
1639 1639
     );
1640 1640
 
1641 1641
 }
@@ -1645,16 +1645,16 @@  discard block
 block discarded – undo
1645 1645
  *
1646 1646
  * @return string
1647 1647
  */
1648
-function getpaid_filter_embed_template( $template ) {
1648
+function getpaid_filter_embed_template($template) {
1649 1649
 
1650
-    if ( isset( $_GET['getpaid_embed'] ) ) {
1651
-        wpinv_get_template( 'payment-forms/embed.php' );
1650
+    if (isset($_GET['getpaid_embed'])) {
1651
+        wpinv_get_template('payment-forms/embed.php');
1652 1652
         exit;
1653 1653
     }
1654 1654
 
1655 1655
     return $template;
1656 1656
 }
1657
-add_filter( 'template_include', 'getpaid_filter_embed_template' );
1657
+add_filter('template_include', 'getpaid_filter_embed_template');
1658 1658
 
1659 1659
 /**
1660 1660
  * Get the payment forms custom fields.
@@ -1666,25 +1666,25 @@  discard block
 block discarded – undo
1666 1666
 function getpaid_get_payment_form_custom_fields() {
1667 1667
 	global $wpdb, $payment_form_meta_fields;
1668 1668
 
1669
-	if ( ! empty( $payment_form_meta_fields ) ) {
1669
+	if (!empty($payment_form_meta_fields)) {
1670 1670
 		return $payment_form_meta_fields;
1671 1671
 	}
1672 1672
 
1673
-	$results = $wpdb->get_results( "SELECT `pm`.`meta_value` FROM `{$wpdb->postmeta}` AS pm LEFT JOIN `{$wpdb->posts}` AS p ON p.ID = pm.post_id WHERE `pm`.`meta_key` = 'wpinv_form_elements' AND `p`.`post_type` = 'wpi_payment_form'" );
1673
+	$results = $wpdb->get_results("SELECT `pm`.`meta_value` FROM `{$wpdb->postmeta}` AS pm LEFT JOIN `{$wpdb->posts}` AS p ON p.ID = pm.post_id WHERE `pm`.`meta_key` = 'wpinv_form_elements' AND `p`.`post_type` = 'wpi_payment_form'");
1674 1674
 
1675 1675
 	$meta_fields = array();
1676 1676
 
1677
-	if ( ! empty( $results ) ) {
1678
-		foreach ( $results as $row ) {
1679
-			$fields = maybe_unserialize( $row->meta_value );
1677
+	if (!empty($results)) {
1678
+		foreach ($results as $row) {
1679
+			$fields = maybe_unserialize($row->meta_value);
1680 1680
 
1681
-			if ( ! empty( $fields ) && is_array( $fields ) ) {
1682
-				foreach ( $fields as $field ) {
1683
-					$label = ! empty( $field['add_meta'] ) && ! empty( $field['label'] ) ? wpinv_clean( wp_unslash( $field['label'] ) ) : '';
1681
+			if (!empty($fields) && is_array($fields)) {
1682
+				foreach ($fields as $field) {
1683
+					$label = !empty($field['add_meta']) && !empty($field['label']) ? wpinv_clean(wp_unslash($field['label'])) : '';
1684 1684
 
1685
-					if ( $label ) {
1686
-						$field_key = '_' . str_replace( array( ' ', "'", '"', ',' ), array( '_', '', '', '_' ), getpaid_strtolower( $label ) );
1687
-						$meta_fields[ $field_key ] = $label;
1685
+					if ($label) {
1686
+						$field_key = '_' . str_replace(array(' ', "'", '"', ','), array('_', '', '', '_'), getpaid_strtolower($label));
1687
+						$meta_fields[$field_key] = $label;
1688 1688
 					}
1689 1689
 				}
1690 1690
 			}
Please login to merge, or discard this patch.
includes/wpinv-helper-functions.php 2 patches
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -137,13 +137,13 @@  discard block
 block discarded – undo
137 137
  */
138 138
 function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
139 139
 
140
-	$invoice_statuses = array(
141
-		'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
140
+    $invoice_statuses = array(
141
+        'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
142 142
         'publish'        => _x( 'Paid', 'Invoice status', 'invoicing' ),
143 143
         'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ),
144
-		'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
145
-		'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
146
-		'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
144
+        'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
145
+        'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
146
+        'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
147 147
         'wpi-failed'     => _x( 'Failed', 'Invoice status', 'invoicing' ),
148 148
         'wpi-renewal'    => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ),
149 149
     );
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         $invoice = $invoice->get_post_type();
161 161
     }
162 162
 
163
-	return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
163
+    return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
164 164
 }
165 165
 
166 166
 /**
@@ -278,25 +278,25 @@  discard block
 block discarded – undo
278 278
  * @return string
279 279
  */
280 280
 function getpaid_get_price_format() {
281
-	$currency_pos = wpinv_currency_position();
282
-	$format       = '%1$s%2$s';
283
-
284
-	switch ( $currency_pos ) {
285
-		case 'left':
286
-			$format = '%1$s%2$s';
287
-			break;
288
-		case 'right':
289
-			$format = '%2$s%1$s';
290
-			break;
291
-		case 'left_space':
292
-			$format = '%1$s&nbsp;%2$s';
293
-			break;
294
-		case 'right_space':
295
-			$format = '%2$s&nbsp;%1$s';
296
-			break;
297
-	}
298
-
299
-	return apply_filters( 'getpaid_price_format', $format, $currency_pos );
281
+    $currency_pos = wpinv_currency_position();
282
+    $format       = '%1$s%2$s';
283
+
284
+    switch ( $currency_pos ) {
285
+        case 'left':
286
+            $format = '%1$s%2$s';
287
+            break;
288
+        case 'right':
289
+            $format = '%2$s%1$s';
290
+            break;
291
+        case 'left_space':
292
+            $format = '%1$s&nbsp;%2$s';
293
+            break;
294
+        case 'right_space':
295
+            $format = '%2$s&nbsp;%1$s';
296
+            break;
297
+    }
298
+
299
+    return apply_filters( 'getpaid_price_format', $format, $currency_pos );
300 300
 }
301 301
 
302 302
 /**
@@ -402,13 +402,13 @@  discard block
 block discarded – undo
402 402
  * @param mixed  $value Value.
403 403
  */
404 404
 function getpaid_maybe_define_constant( $name, $value ) {
405
-	if ( ! defined( $name ) ) {
406
-		define( $name, $value );
407
-	}
405
+    if ( ! defined( $name ) ) {
406
+        define( $name, $value );
407
+    }
408 408
 }
409 409
 
410 410
 function wpinv_get_php_arg_separator_output() {
411
-	return ini_get( 'arg_separator.output' );
411
+    return ini_get( 'arg_separator.output' );
412 412
 }
413 413
 
414 414
 function wpinv_rgb_from_hex( $color ) {
@@ -719,16 +719,16 @@  discard block
 block discarded – undo
719 719
     return wp_kses(
720 720
         html_entity_decode( $var ),
721 721
         array(
722
-			'br'     => array(),
723
-			'em'     => array(),
724
-			'strong' => array(),
725
-			'b'      => array(),
726
-			'small'  => array(),
727
-			'span'   => array(),
728
-			'ul'     => array(),
729
-			'li'     => array(),
730
-			'ol'     => array(),
731
-			'p'      => array(),
722
+            'br'     => array(),
723
+            'em'     => array(),
724
+            'strong' => array(),
725
+            'b'      => array(),
726
+            'small'  => array(),
727
+            'span'   => array(),
728
+            'ul'     => array(),
729
+            'li'     => array(),
730
+            'ol'     => array(),
731
+            'p'      => array(),
732 732
         )
733 733
     );
734 734
 }
@@ -779,11 +779,11 @@  discard block
 block discarded – undo
779 779
         $list = array();
780 780
     }
781 781
 
782
-	if ( ! is_array( $list ) ) {
783
-		return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
784
-	}
782
+    if ( ! is_array( $list ) ) {
783
+        return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
784
+    }
785 785
 
786
-	return $list;
786
+    return $list;
787 787
 }
788 788
 
789 789
 /**
@@ -824,17 +824,17 @@  discard block
 block discarded – undo
824 824
  */
825 825
 function wpinv_clean( $var ) {
826 826
 
827
-	if ( is_array( $var ) ) {
828
-		return array_map( 'wpinv_clean', $var );
827
+    if ( is_array( $var ) ) {
828
+        return array_map( 'wpinv_clean', $var );
829 829
     }
830 830
 
831 831
     if ( is_object( $var ) ) {
832
-		$object_vars = get_object_vars( $var );
833
-		foreach ( $object_vars as $property_name => $property_value ) {
834
-			$var->$property_name = wpinv_clean( $property_value );
832
+        $object_vars = get_object_vars( $var );
833
+        foreach ( $object_vars as $property_name => $property_value ) {
834
+            $var->$property_name = wpinv_clean( $property_value );
835 835
         }
836 836
         return $var;
837
-	}
837
+    }
838 838
 
839 839
     return is_string( $var ) ? sanitize_text_field( stripslashes( $var ) ) : $var;
840 840
 }
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
  */
848 848
 function getpaid_convert_price_string_to_options( $str ) {
849 849
 
850
-	$raw_options = array_map( 'trim', explode( ',', $str ) );
850
+    $raw_options = array_map( 'trim', explode( ',', $str ) );
851 851
     $options     = array();
852 852
 
853 853
     foreach ( $raw_options as $option ) {
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
  * @return string
937 937
  */
938 938
 function getpaid_date_format() {
939
-	return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
939
+    return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
940 940
 }
941 941
 
942 942
 /**
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
  * @return string
946 946
  */
947 947
 function getpaid_time_format() {
948
-	return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
948
+    return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
949 949
 }
950 950
 
951 951
 /**
@@ -958,15 +958,15 @@  discard block
 block discarded – undo
958 958
 function getpaid_limit_length( $string, $limit ) {
959 959
     $str_limit = $limit - 3;
960 960
 
961
-	if ( function_exists( 'mb_strimwidth' ) ) {
962
-		if ( mb_strlen( $string ) > $limit ) {
963
-			$string = mb_strimwidth( $string, 0, $str_limit ) . '...';
964
-		}
965
-	} else {
966
-		if ( strlen( $string ) > $limit ) {
967
-			$string = substr( $string, 0, $str_limit ) . '...';
968
-		}
969
-	}
961
+    if ( function_exists( 'mb_strimwidth' ) ) {
962
+        if ( mb_strlen( $string ) > $limit ) {
963
+            $string = mb_strimwidth( $string, 0, $str_limit ) . '...';
964
+        }
965
+    } else {
966
+        if ( strlen( $string ) > $limit ) {
967
+            $string = substr( $string, 0, $str_limit ) . '...';
968
+        }
969
+    }
970 970
     return $string;
971 971
 
972 972
 }
@@ -1096,12 +1096,12 @@  discard block
 block discarded – undo
1096 1096
     $types = get_allowed_mime_types();
1097 1097
 
1098 1098
     if ( isset( $types['htm|html'] ) ) {
1099
-		unset( $types['htm|html'] );
1100
-	}
1099
+        unset( $types['htm|html'] );
1100
+    }
1101 1101
 
1102 1102
     if ( isset( $types['js'] ) ) {
1103
-		unset( $types['js'] );
1104
-	}
1103
+        unset( $types['js'] );
1104
+    }
1105 1105
 
1106 1106
     return $types;
1107 1107
 
@@ -1157,11 +1157,11 @@  discard block
 block discarded – undo
1157 1157
  * @return string Returns converted string.
1158 1158
  */
1159 1159
 function getpaid_strtolower( $string, $charset = 'UTF-8' ) {
1160
-	if ( function_exists( 'mb_convert_case' ) ) {
1161
-		return mb_convert_case( $string, MB_CASE_LOWER, $charset );
1162
-	} else {
1163
-		return strtolower( $string );
1164
-	}
1160
+    if ( function_exists( 'mb_convert_case' ) ) {
1161
+        return mb_convert_case( $string, MB_CASE_LOWER, $charset );
1162
+    } else {
1163
+        return strtolower( $string );
1164
+    }
1165 1165
 }
1166 1166
 
1167 1167
 /**
@@ -1174,9 +1174,9 @@  discard block
 block discarded – undo
1174 1174
  * @return string Returns converted string.
1175 1175
  */
1176 1176
 function getpaid_strtoupper( $string, $charset = 'UTF-8' ) {
1177
-	if ( function_exists( 'mb_convert_case' ) ) {
1178
-		return mb_convert_case( $string, MB_CASE_UPPER, $charset );
1179
-	} else {
1180
-		return strtoupper( $string );
1181
-	}
1177
+    if ( function_exists( 'mb_convert_case' ) ) {
1178
+        return mb_convert_case( $string, MB_CASE_UPPER, $charset );
1179
+    } else {
1180
+        return strtoupper( $string );
1181
+    }
1182 1182
 }
1183 1183
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +294 added lines, -294 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
  * Are we supporting item quantities?
@@ -20,35 +20,35 @@  discard block
 block discarded – undo
20 20
  */
21 21
 function wpinv_get_ip() {
22 22
 
23
-    if ( isset( $_SERVER['HTTP_X_REAL_IP'] ) ) {
24
-        return sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REAL_IP'] ) );
23
+    if (isset($_SERVER['HTTP_X_REAL_IP'])) {
24
+        return sanitize_text_field(wp_unslash($_SERVER['HTTP_X_REAL_IP']));
25 25
     }
26 26
 
27
-    if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
27
+    if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
28 28
         // Proxy servers can send through this header like this: X-Forwarded-For: client1, proxy1, proxy2
29 29
         // Make sure we always only send through the first IP in the list which should always be the client IP.
30
-        return (string) rest_is_ip_address( trim( current( preg_split( '/,/', sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) ) ) );
30
+        return (string) rest_is_ip_address(trim(current(preg_split('/,/', sanitize_text_field(wp_unslash($_SERVER['HTTP_X_FORWARDED_FOR']))))));
31 31
     }
32 32
 
33
-    if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) {
34
-        return sanitize_text_field( wp_unslash( $_SERVER['HTTP_CLIENT_IP'] ) );
33
+    if (isset($_SERVER['HTTP_CLIENT_IP'])) {
34
+        return sanitize_text_field(wp_unslash($_SERVER['HTTP_CLIENT_IP']));
35 35
     }
36 36
 
37
-    if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
38
-        return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) );
37
+    if (isset($_SERVER['REMOTE_ADDR'])) {
38
+        return sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR']));
39 39
     }
40 40
 
41 41
     return '';
42 42
 }
43 43
 
44 44
 function wpinv_get_user_agent() {
45
-    if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
46
-        $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] );
45
+    if (!empty($_SERVER['HTTP_USER_AGENT'])) {
46
+        $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']);
47 47
     } else {
48 48
         $user_agent = '';
49 49
     }
50 50
 
51
-    return apply_filters( 'wpinv_get_user_agent', $user_agent );
51
+    return apply_filters('wpinv_get_user_agent', $user_agent);
52 52
 }
53 53
 
54 54
 /**
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
  * @param string $amount The amount to sanitize.
58 58
  * @return float
59 59
  */
60
-function getpaid_standardize_amount( $amount ) {
60
+function getpaid_standardize_amount($amount) {
61 61
 
62
-    $amount = str_replace( wpinv_thousands_separator(), '', $amount );
63
-    $amount = str_replace( wpinv_decimal_separator(), '.', $amount );
64
-    if ( is_numeric( $amount ) ) {
65
-        return floatval( $amount );
62
+    $amount = str_replace(wpinv_thousands_separator(), '', $amount);
63
+    $amount = str_replace(wpinv_decimal_separator(), '.', $amount);
64
+    if (is_numeric($amount)) {
65
+        return floatval($amount);
66 66
     }
67 67
 
68 68
     // Cast the remaining to a float.
69
-    return wpinv_round_amount( preg_replace( '/[^0-9\.\-]/', '', $amount ) );
69
+    return wpinv_round_amount(preg_replace('/[^0-9\.\-]/', '', $amount));
70 70
 
71 71
 }
72 72
 
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
  *
76 76
  * @param string $amount The amount to sanitize.
77 77
  */
78
-function getpaid_unstandardize_amount( $amount ) {
79
-    return str_replace( '.', wpinv_decimal_separator(), $amount );
78
+function getpaid_unstandardize_amount($amount) {
79
+    return str_replace('.', wpinv_decimal_separator(), $amount);
80 80
 }
81 81
 
82 82
 /**
@@ -84,24 +84,24 @@  discard block
 block discarded – undo
84 84
  *
85 85
  * @param string $amount The amount to sanitize.
86 86
  */
87
-function wpinv_sanitize_amount( $amount ) {
87
+function wpinv_sanitize_amount($amount) {
88 88
 
89
-    if ( is_numeric( $amount ) ) {
90
-        return floatval( $amount );
89
+    if (is_numeric($amount)) {
90
+        return floatval($amount);
91 91
     }
92 92
 
93 93
     // Separate the decimals and thousands.
94
-    $amount    = empty( $amount ) ? '0' : (string) $amount;
95
-    $amount    = explode( wpinv_decimal_separator(), $amount );
94
+    $amount    = empty($amount) ? '0' : (string) $amount;
95
+    $amount    = explode(wpinv_decimal_separator(), $amount);
96 96
 
97 97
     // Remove thousands.
98
-    $amount[0] = str_replace( wpinv_thousands_separator(), '', $amount[0] );
98
+    $amount[0] = str_replace(wpinv_thousands_separator(), '', $amount[0]);
99 99
 
100 100
     // Convert back to string.
101
-    $amount = count( $amount ) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0];
101
+    $amount = count($amount) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0];
102 102
 
103 103
     // Cast the remaining to a float.
104
-    return (float) preg_replace( '/[^0-9\.\-]/', '', $amount );
104
+    return (float) preg_replace('/[^0-9\.\-]/', '', $amount);
105 105
 
106 106
 }
107 107
 
@@ -111,19 +111,19 @@  discard block
 block discarded – undo
111 111
  * @param float $amount
112 112
  * @param float|string|int|null $decimals
113 113
  */
114
-function wpinv_round_amount( $amount, $decimals = null, $use_sprintf = false ) {
114
+function wpinv_round_amount($amount, $decimals = null, $use_sprintf = false) {
115 115
 
116
-    if ( $decimals === null ) {
116
+    if ($decimals === null) {
117 117
         $decimals = wpinv_decimals();
118 118
     }
119 119
 
120
-    if ( $use_sprintf ) {
121
-        $amount = sprintf( "%.{$decimals}f", (float) $amount );
120
+    if ($use_sprintf) {
121
+        $amount = sprintf("%.{$decimals}f", (float) $amount);
122 122
     } else {
123
-        $amount = round( (float) $amount, absint( $decimals ) );
123
+        $amount = round((float) $amount, absint($decimals));
124 124
     }
125 125
 
126
-    return apply_filters( 'wpinv_round_amount', $amount, $decimals );
126
+    return apply_filters('wpinv_round_amount', $amount, $decimals);
127 127
 }
128 128
 
129 129
 /**
@@ -135,32 +135,32 @@  discard block
 block discarded – undo
135 135
  * @param string|WPInv_Invoice $invoice The invoice object|post type|type
136 136
  * @return array
137 137
  */
138
-function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
138
+function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) {
139 139
 
140 140
 	$invoice_statuses = array(
141
-		'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
142
-        'publish'        => _x( 'Paid', 'Invoice status', 'invoicing' ),
143
-        'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ),
144
-		'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
145
-		'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
146
-		'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
147
-        'wpi-failed'     => _x( 'Failed', 'Invoice status', 'invoicing' ),
148
-        'wpi-renewal'    => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ),
141
+		'wpi-pending'    => _x('Pending payment', 'Invoice status', 'invoicing'),
142
+        'publish'        => _x('Paid', 'Invoice status', 'invoicing'),
143
+        'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'),
144
+		'wpi-onhold'     => _x('On hold', 'Invoice status', 'invoicing'),
145
+		'wpi-cancelled'  => _x('Cancelled', 'Invoice status', 'invoicing'),
146
+		'wpi-refunded'   => _x('Refunded', 'Invoice status', 'invoicing'),
147
+        'wpi-failed'     => _x('Failed', 'Invoice status', 'invoicing'),
148
+        'wpi-renewal'    => _x('Renewal Payment', 'Invoice status', 'invoicing'),
149 149
     );
150 150
 
151
-    if ( $draft ) {
152
-        $invoice_statuses['draft'] = __( 'Draft', 'invoicing' );
151
+    if ($draft) {
152
+        $invoice_statuses['draft'] = __('Draft', 'invoicing');
153 153
     }
154 154
 
155
-    if ( $trashed ) {
156
-        $invoice_statuses['trash'] = __( 'Trash', 'invoicing' );
155
+    if ($trashed) {
156
+        $invoice_statuses['trash'] = __('Trash', 'invoicing');
157 157
     }
158 158
 
159
-    if ( $invoice instanceof WPInv_Invoice ) {
159
+    if ($invoice instanceof WPInv_Invoice) {
160 160
         $invoice = $invoice->get_post_type();
161 161
     }
162 162
 
163
-	return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
163
+	return apply_filters('wpinv_statuses', $invoice_statuses, $invoice);
164 164
 }
165 165
 
166 166
 /**
@@ -169,11 +169,11 @@  discard block
 block discarded – undo
169 169
  * @param string $status The raw status
170 170
  * @param string|WPInv_Invoice $invoice The invoice object|post type|type
171 171
  */
172
-function wpinv_status_nicename( $status, $invoice = false ) {
173
-    $statuses = wpinv_get_invoice_statuses( true, true, $invoice );
174
-    $status   = isset( $statuses[ $status ] ) ? $statuses[ $status ] : $status;
172
+function wpinv_status_nicename($status, $invoice = false) {
173
+    $statuses = wpinv_get_invoice_statuses(true, true, $invoice);
174
+    $status   = isset($statuses[$status]) ? $statuses[$status] : $status;
175 175
 
176
-    return sanitize_text_field( $status );
176
+    return sanitize_text_field($status);
177 177
 }
178 178
 
179 179
 /**
@@ -181,13 +181,13 @@  discard block
 block discarded – undo
181 181
  *
182 182
  * @param string $current
183 183
  */
184
-function wpinv_get_currency( $current = '' ) {
184
+function wpinv_get_currency($current = '') {
185 185
 
186
-    if ( empty( $current ) ) {
187
-        $current = apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) );
186
+    if (empty($current)) {
187
+        $current = apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD'));
188 188
     }
189 189
 
190
-    return trim( strtoupper( $current ) );
190
+    return trim(strtoupper($current));
191 191
 }
192 192
 
193 193
 /**
@@ -195,25 +195,25 @@  discard block
 block discarded – undo
195 195
  *
196 196
  * @param string|null $currency The currency code. Defaults to the default currency.
197 197
  */
198
-function wpinv_currency_symbol( $currency = null ) {
198
+function wpinv_currency_symbol($currency = null) {
199 199
 
200 200
     // Prepare the currency.
201
-    $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency );
201
+    $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency);
202 202
 
203 203
     // Fetch all symbols.
204 204
     $symbols = wpinv_get_currency_symbols();
205 205
 
206 206
     // Fetch this currencies symbol.
207
-    $currency_symbol = isset( $symbols[ $currency ] ) ? $symbols[ $currency ] : $currency;
207
+    $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency;
208 208
 
209 209
     // Filter the symbol.
210
-    return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency );
210
+    return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency);
211 211
 }
212 212
 
213 213
 function wpinv_currency_position() {
214
-    $position = wpinv_get_option( 'currency_position', 'left' );
214
+    $position = wpinv_get_option('currency_position', 'left');
215 215
 
216
-    return apply_filters( 'wpinv_currency_position', $position );
216
+    return apply_filters('wpinv_currency_position', $position);
217 217
 }
218 218
 
219 219
 /**
@@ -221,13 +221,13 @@  discard block
 block discarded – undo
221 221
  *
222 222
  * @param $string|null $current
223 223
  */
224
-function wpinv_thousands_separator( $current = null ) {
224
+function wpinv_thousands_separator($current = null) {
225 225
 
226
-    if ( null == $current ) {
227
-        $current = wpinv_get_option( 'thousands_separator', ',' );
226
+    if (null == $current) {
227
+        $current = wpinv_get_option('thousands_separator', ',');
228 228
     }
229 229
 
230
-    return trim( $current );
230
+    return trim($current);
231 231
 }
232 232
 
233 233
 /**
@@ -235,13 +235,13 @@  discard block
 block discarded – undo
235 235
  *
236 236
  * @param $string|null $current
237 237
  */
238
-function wpinv_decimal_separator( $current = null ) {
238
+function wpinv_decimal_separator($current = null) {
239 239
 
240
-    if ( null == $current ) {
241
-        $current = wpinv_get_option( 'decimal_separator', '.' );
240
+    if (null == $current) {
241
+        $current = wpinv_get_option('decimal_separator', '.');
242 242
     }
243 243
 
244
-    return trim( $current );
244
+    return trim($current);
245 245
 }
246 246
 
247 247
 /**
@@ -249,27 +249,27 @@  discard block
 block discarded – undo
249 249
  *
250 250
  * @param $string|null $current
251 251
  */
252
-function wpinv_decimals( $current = null ) {
252
+function wpinv_decimals($current = null) {
253 253
 
254
-    if ( null == $current ) {
255
-        $current = wpinv_get_option( 'decimals', 2 );
254
+    if (null == $current) {
255
+        $current = wpinv_get_option('decimals', 2);
256 256
     }
257 257
 
258
-    return absint( $current );
258
+    return absint($current);
259 259
 }
260 260
 
261 261
 /**
262 262
  * Retrieves a list of all supported currencies.
263 263
  */
264 264
 function wpinv_get_currencies() {
265
-    return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) );
265
+    return apply_filters('wpinv_currencies', wpinv_get_data('currencies'));
266 266
 }
267 267
 
268 268
 /**
269 269
  * Retrieves a list of all currency symbols.
270 270
  */
271 271
 function wpinv_get_currency_symbols() {
272
-    return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) );
272
+    return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols'));
273 273
 }
274 274
 
275 275
 /**
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
 	$currency_pos = wpinv_currency_position();
282 282
 	$format       = '%1$s%2$s';
283 283
 
284
-	switch ( $currency_pos ) {
284
+	switch ($currency_pos) {
285 285
 		case 'left':
286 286
 			$format = '%1$s%2$s';
287 287
 			break;
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 			break;
297 297
 	}
298 298
 
299
-	return apply_filters( 'getpaid_price_format', $format, $currency_pos );
299
+	return apply_filters('getpaid_price_format', $format, $currency_pos);
300 300
 }
301 301
 
302 302
 /**
@@ -306,8 +306,8 @@  discard block
 block discarded – undo
306 306
  * @param  string $currency Currency.
307 307
  * @return string
308 308
  */
309
-function wpinv_the_price( $amount = 0, $currency = '' ) {
310
-    echo wp_kses_post( wpinv_price( $amount, $currency ) );
309
+function wpinv_the_price($amount = 0, $currency = '') {
310
+    echo wp_kses_post(wpinv_price($amount, $currency));
311 311
 }
312 312
 
313 313
 /**
@@ -317,25 +317,25 @@  discard block
 block discarded – undo
317 317
  * @param  string $currency Currency.
318 318
  * @return string
319 319
  */
320
-function wpinv_price( $amount = 0, $currency = '' ) {
320
+function wpinv_price($amount = 0, $currency = '') {
321 321
 
322 322
     // Backwards compatibility.
323
-    $amount             = wpinv_sanitize_amount( $amount );
323
+    $amount             = wpinv_sanitize_amount($amount);
324 324
 
325 325
     // Prepare variables.
326
-    $currency           = wpinv_get_currency( $currency );
326
+    $currency           = wpinv_get_currency($currency);
327 327
     $amount             = (float) $amount;
328 328
     $unformatted_amount = $amount;
329 329
     $negative           = $amount < 0;
330
-    $amount             = apply_filters( 'getpaid_raw_amount', floatval( $negative ? $amount * -1 : $amount ) );
331
-    $amount             = wpinv_format_amount( $amount );
330
+    $amount             = apply_filters('getpaid_raw_amount', floatval($negative ? $amount * -1 : $amount));
331
+    $amount             = wpinv_format_amount($amount);
332 332
 
333 333
     // Format the amount.
334 334
     $format             = getpaid_get_price_format();
335
-    $formatted_amount   = ( $negative ? '-' : '' ) . sprintf( $format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol( $currency ) . '</span>', $amount );
335
+    $formatted_amount   = ($negative ? '-' : '') . sprintf($format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol($currency) . '</span>', $amount);
336 336
 
337 337
     // Filter the formatting.
338
-    return apply_filters( 'wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount );
338
+    return apply_filters('wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount);
339 339
 }
340 340
 
341 341
 /**
@@ -346,25 +346,25 @@  discard block
 block discarded – undo
346 346
  * @param  bool     $calculate Whether or not to apply separators.
347 347
  * @return string
348 348
  */
349
-function wpinv_format_amount( $amount, $decimals = null, $calculate = false ) {
349
+function wpinv_format_amount($amount, $decimals = null, $calculate = false) {
350 350
     $thousands_sep = wpinv_thousands_separator();
351 351
     $decimal_sep   = wpinv_decimal_separator();
352
-    $decimals      = wpinv_decimals( $decimals );
353
-    $amount        = wpinv_sanitize_amount( $amount );
352
+    $decimals      = wpinv_decimals($decimals);
353
+    $amount        = wpinv_sanitize_amount($amount);
354 354
 
355
-    if ( $calculate ) {
355
+    if ($calculate) {
356 356
         return $amount;
357 357
     }
358 358
 
359 359
     // Fomart the amount.
360
-    return number_format( $amount, $decimals, $decimal_sep, $thousands_sep );
360
+    return number_format($amount, $decimals, $decimal_sep, $thousands_sep);
361 361
 }
362 362
 
363
-function wpinv_sanitize_key( $key ) {
363
+function wpinv_sanitize_key($key) {
364 364
     $raw_key = $key;
365
-    $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
365
+    $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key);
366 366
 
367
-    return apply_filters( 'wpinv_sanitize_key', $key, $raw_key );
367
+    return apply_filters('wpinv_sanitize_key', $key, $raw_key);
368 368
 }
369 369
 
370 370
 /**
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
  *
373 373
  * @param $str the file whose extension should be retrieved.
374 374
  */
375
-function wpinv_get_file_extension( $str ) {
376
-    $filetype = wp_check_filetype( $str );
375
+function wpinv_get_file_extension($str) {
376
+    $filetype = wp_check_filetype($str);
377 377
     return $filetype['ext'];
378 378
 }
379 379
 
@@ -382,16 +382,16 @@  discard block
 block discarded – undo
382 382
  *
383 383
  * @param string $string
384 384
  */
385
-function wpinv_string_is_image_url( $string ) {
386
-    $extension = strtolower( wpinv_get_file_extension( $string ) );
387
-    return in_array( $extension, array( 'jpeg', 'jpg', 'png', 'gif', 'ico' ), true );
385
+function wpinv_string_is_image_url($string) {
386
+    $extension = strtolower(wpinv_get_file_extension($string));
387
+    return in_array($extension, array('jpeg', 'jpg', 'png', 'gif', 'ico'), true);
388 388
 }
389 389
 
390 390
 /**
391 391
  * Returns the current URL.
392 392
  */
393 393
 function wpinv_get_current_page_url() {
394
-    return esc_url( add_query_arg( array() ) );
394
+    return esc_url(add_query_arg(array()));
395 395
 }
396 396
 
397 397
 /**
@@ -401,46 +401,46 @@  discard block
 block discarded – undo
401 401
  * @param string $name  Constant name.
402 402
  * @param mixed  $value Value.
403 403
  */
404
-function getpaid_maybe_define_constant( $name, $value ) {
405
-	if ( ! defined( $name ) ) {
406
-		define( $name, $value );
404
+function getpaid_maybe_define_constant($name, $value) {
405
+	if (!defined($name)) {
406
+		define($name, $value);
407 407
 	}
408 408
 }
409 409
 
410 410
 function wpinv_get_php_arg_separator_output() {
411
-	return ini_get( 'arg_separator.output' );
411
+	return ini_get('arg_separator.output');
412 412
 }
413 413
 
414
-function wpinv_rgb_from_hex( $color ) {
415
-    $color = str_replace( '#', '', $color );
414
+function wpinv_rgb_from_hex($color) {
415
+    $color = str_replace('#', '', $color);
416 416
 
417 417
     // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF"
418
-    $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color );
419
-    if ( empty( $color ) ) {
418
+    $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color);
419
+    if (empty($color)) {
420 420
         return null;
421 421
     }
422 422
 
423
-    $color = str_split( $color );
423
+    $color = str_split($color);
424 424
 
425 425
     $rgb      = array();
426
-    $rgb['R'] = hexdec( $color[0] . $color[1] );
427
-    $rgb['G'] = hexdec( $color[2] . $color[3] );
428
-    $rgb['B'] = hexdec( $color[4] . $color[5] );
426
+    $rgb['R'] = hexdec($color[0] . $color[1]);
427
+    $rgb['G'] = hexdec($color[2] . $color[3]);
428
+    $rgb['B'] = hexdec($color[4] . $color[5]);
429 429
 
430 430
     return $rgb;
431 431
 }
432 432
 
433
-function wpinv_hex_darker( $color, $factor = 30 ) {
434
-    $base  = wpinv_rgb_from_hex( $color );
433
+function wpinv_hex_darker($color, $factor = 30) {
434
+    $base  = wpinv_rgb_from_hex($color);
435 435
     $color = '#';
436 436
 
437
-    foreach ( $base as $k => $v ) {
437
+    foreach ($base as $k => $v) {
438 438
         $amount      = $v / 100;
439
-        $amount      = round( $amount * $factor );
439
+        $amount      = round($amount * $factor);
440 440
         $new_decimal = $v - $amount;
441 441
 
442
-        $new_hex_component = dechex( $new_decimal );
443
-        if ( strlen( $new_hex_component ) < 2 ) {
442
+        $new_hex_component = dechex($new_decimal);
443
+        if (strlen($new_hex_component) < 2) {
444 444
             $new_hex_component = '0' . $new_hex_component;
445 445
         }
446 446
         $color .= $new_hex_component;
@@ -449,18 +449,18 @@  discard block
 block discarded – undo
449 449
     return $color;
450 450
 }
451 451
 
452
-function wpinv_hex_lighter( $color, $factor = 30 ) {
453
-    $base  = wpinv_rgb_from_hex( $color );
452
+function wpinv_hex_lighter($color, $factor = 30) {
453
+    $base  = wpinv_rgb_from_hex($color);
454 454
     $color = '#';
455 455
 
456
-    foreach ( $base as $k => $v ) {
456
+    foreach ($base as $k => $v) {
457 457
         $amount      = 255 - $v;
458 458
         $amount      = $amount / 100;
459
-        $amount      = round( $amount * $factor );
459
+        $amount      = round($amount * $factor);
460 460
         $new_decimal = $v + $amount;
461 461
 
462
-        $new_hex_component = dechex( $new_decimal );
463
-        if ( strlen( $new_hex_component ) < 2 ) {
462
+        $new_hex_component = dechex($new_decimal);
463
+        if (strlen($new_hex_component) < 2) {
464 464
             $new_hex_component = '0' . $new_hex_component;
465 465
         }
466 466
         $color .= $new_hex_component;
@@ -469,22 +469,22 @@  discard block
 block discarded – undo
469 469
     return $color;
470 470
 }
471 471
 
472
-function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) {
473
-    $hex = str_replace( '#', '', $color );
472
+function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') {
473
+    $hex = str_replace('#', '', $color);
474 474
 
475
-    $c_r = hexdec( substr( $hex, 0, 2 ) );
476
-    $c_g = hexdec( substr( $hex, 2, 2 ) );
477
-    $c_b = hexdec( substr( $hex, 4, 2 ) );
475
+    $c_r = hexdec(substr($hex, 0, 2));
476
+    $c_g = hexdec(substr($hex, 2, 2));
477
+    $c_b = hexdec(substr($hex, 4, 2));
478 478
 
479
-    $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
479
+    $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000;
480 480
 
481 481
     return $brightness > 155 ? $dark : $light;
482 482
 }
483 483
 
484
-function wpinv_format_hex( $hex ) {
485
-    $hex = trim( str_replace( '#', '', $hex ) );
484
+function wpinv_format_hex($hex) {
485
+    $hex = trim(str_replace('#', '', $hex));
486 486
 
487
-    if ( strlen( $hex ) == 3 ) {
487
+    if (strlen($hex) == 3) {
488 488
         $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
489 489
     }
490 490
 
@@ -504,12 +504,12 @@  discard block
 block discarded – undo
504 504
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
505 505
  * @return string
506 506
  */
507
-function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) {
508
-    if ( function_exists( 'mb_strimwidth' ) ) {
509
-        return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding );
507
+function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') {
508
+    if (function_exists('mb_strimwidth')) {
509
+        return mb_strimwidth($str, $start, $width, $trimmaker, $encoding);
510 510
     }
511 511
 
512
-    return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker;
512
+    return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker;
513 513
 }
514 514
 
515 515
 /**
@@ -521,28 +521,28 @@  discard block
 block discarded – undo
521 521
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
522 522
  * @return int Returns the number of characters in string.
523 523
  */
524
-function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) {
525
-    if ( function_exists( 'mb_strlen' ) ) {
526
-        return mb_strlen( $str, $encoding );
524
+function wpinv_utf8_strlen($str, $encoding = 'UTF-8') {
525
+    if (function_exists('mb_strlen')) {
526
+        return mb_strlen($str, $encoding);
527 527
     }
528 528
 
529
-    return strlen( $str );
529
+    return strlen($str);
530 530
 }
531 531
 
532
-function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) {
533
-    if ( function_exists( 'mb_strtolower' ) ) {
534
-        return mb_strtolower( $str, $encoding );
532
+function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') {
533
+    if (function_exists('mb_strtolower')) {
534
+        return mb_strtolower($str, $encoding);
535 535
     }
536 536
 
537
-    return strtolower( $str );
537
+    return strtolower($str);
538 538
 }
539 539
 
540
-function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) {
541
-    if ( function_exists( 'mb_strtoupper' ) ) {
542
-        return mb_strtoupper( $str, $encoding );
540
+function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') {
541
+    if (function_exists('mb_strtoupper')) {
542
+        return mb_strtoupper($str, $encoding);
543 543
     }
544 544
 
545
-    return strtoupper( $str );
545
+    return strtoupper($str);
546 546
 }
547 547
 
548 548
 /**
@@ -556,12 +556,12 @@  discard block
 block discarded – undo
556 556
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
557 557
  * @return int Returns the position of the first occurrence of search in the string.
558 558
  */
559
-function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
560
-    if ( function_exists( 'mb_strpos' ) ) {
561
-        return mb_strpos( $str, $find, $offset, $encoding );
559
+function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
560
+    if (function_exists('mb_strpos')) {
561
+        return mb_strpos($str, $find, $offset, $encoding);
562 562
     }
563 563
 
564
-    return strpos( $str, $find, $offset );
564
+    return strpos($str, $find, $offset);
565 565
 }
566 566
 
567 567
 /**
@@ -575,12 +575,12 @@  discard block
 block discarded – undo
575 575
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
576 576
  * @return int Returns the position of the last occurrence of search.
577 577
  */
578
-function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
579
-    if ( function_exists( 'mb_strrpos' ) ) {
580
-        return mb_strrpos( $str, $find, $offset, $encoding );
578
+function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
579
+    if (function_exists('mb_strrpos')) {
580
+        return mb_strrpos($str, $find, $offset, $encoding);
581 581
     }
582 582
 
583
-    return strrpos( $str, $find, $offset );
583
+    return strrpos($str, $find, $offset);
584 584
 }
585 585
 
586 586
 /**
@@ -595,16 +595,16 @@  discard block
 block discarded – undo
595 595
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
596 596
  * @return string
597 597
  */
598
-function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) {
599
-    if ( function_exists( 'mb_substr' ) ) {
600
-        if ( null === $length ) {
601
-            return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding );
598
+function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') {
599
+    if (function_exists('mb_substr')) {
600
+        if (null === $length) {
601
+            return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding);
602 602
         } else {
603
-            return mb_substr( $str, $start, $length, $encoding );
603
+            return mb_substr($str, $start, $length, $encoding);
604 604
         }
605 605
     }
606 606
 
607
-    return substr( $str, $start, $length );
607
+    return substr($str, $start, $length);
608 608
 }
609 609
 
610 610
 /**
@@ -616,48 +616,48 @@  discard block
 block discarded – undo
616 616
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
617 617
  * @return string The width of string.
618 618
  */
619
-function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) {
620
-    if ( function_exists( 'mb_strwidth' ) ) {
621
-        return mb_strwidth( $str, $encoding );
619
+function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') {
620
+    if (function_exists('mb_strwidth')) {
621
+        return mb_strwidth($str, $encoding);
622 622
     }
623 623
 
624
-    return wpinv_utf8_strlen( $str, $encoding );
624
+    return wpinv_utf8_strlen($str, $encoding);
625 625
 }
626 626
 
627
-function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) {
628
-    if ( function_exists( 'mb_strlen' ) ) {
629
-        $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding );
627
+function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') {
628
+    if (function_exists('mb_strlen')) {
629
+        $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding);
630 630
         $str_end = '';
631 631
 
632
-        if ( $lower_str_end ) {
633
-            $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding );
632
+        if ($lower_str_end) {
633
+            $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding);
634 634
         } else {
635
-            $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding );
635
+            $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding);
636 636
         }
637 637
 
638 638
         return $first_letter . $str_end;
639 639
     }
640 640
 
641
-    return ucfirst( $str );
641
+    return ucfirst($str);
642 642
 }
643 643
 
644
-function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) {
645
-    if ( function_exists( 'mb_convert_case' ) ) {
646
-        return mb_convert_case( $str, MB_CASE_TITLE, $encoding );
644
+function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') {
645
+    if (function_exists('mb_convert_case')) {
646
+        return mb_convert_case($str, MB_CASE_TITLE, $encoding);
647 647
     }
648 648
 
649
-    return ucwords( $str );
649
+    return ucwords($str);
650 650
 }
651 651
 
652
-function wpinv_period_in_days( $period, $unit ) {
653
-    $period = absint( $period );
652
+function wpinv_period_in_days($period, $unit) {
653
+    $period = absint($period);
654 654
 
655
-    if ( $period > 0 ) {
656
-        if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) {
655
+    if ($period > 0) {
656
+        if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) {
657 657
             $period = $period * 7;
658
-        } elseif ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) {
658
+        } elseif (in_array(strtolower($unit), array('m', 'month', 'months'))) {
659 659
             $period = $period * 30;
660
-        } elseif ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) {
660
+        } elseif (in_array(strtolower($unit), array('y', 'year', 'years'))) {
661 661
             $period = $period * 365;
662 662
         }
663 663
     }
@@ -665,14 +665,14 @@  discard block
 block discarded – undo
665 665
     return $period;
666 666
 }
667 667
 
668
-function wpinv_cal_days_in_month( $calendar, $month, $year ) {
669
-    if ( function_exists( 'cal_days_in_month' ) ) {
670
-        return cal_days_in_month( $calendar, $month, $year );
668
+function wpinv_cal_days_in_month($calendar, $month, $year) {
669
+    if (function_exists('cal_days_in_month')) {
670
+        return cal_days_in_month($calendar, $month, $year);
671 671
     }
672 672
 
673 673
     // Fallback in case the calendar extension is not loaded in PHP
674 674
     // Only supports Gregorian calendar
675
-    return gmdate( 't', mktime( 0, 0, 0, $month, 1, $year ) );
675
+    return gmdate('t', mktime(0, 0, 0, $month, 1, $year));
676 676
 }
677 677
 
678 678
 /**
@@ -683,27 +683,27 @@  discard block
 block discarded – undo
683 683
  *
684 684
  * @return string
685 685
  */
686
-function wpi_help_tip( $tip, $allow_html = false, $is_vue = false, $echo = false ) {
686
+function wpi_help_tip($tip, $allow_html = false, $is_vue = false, $echo = false) {
687 687
 
688
-    if ( $allow_html ) {
689
-        $tip = wpi_sanitize_tooltip( $tip );
688
+    if ($allow_html) {
689
+        $tip = wpi_sanitize_tooltip($tip);
690 690
     } else {
691
-        $tip = strip_tags( $tip );
691
+        $tip = strip_tags($tip);
692 692
     }
693 693
 
694
-    if ( $is_vue ) {
694
+    if ($is_vue) {
695 695
 
696
-        if ( $echo ) {
697
-            echo '<span class="dashicons dashicons-editor-help" title="' . esc_attr( $tip ) . '"></span>';
696
+        if ($echo) {
697
+            echo '<span class="dashicons dashicons-editor-help" title="' . esc_attr($tip) . '"></span>';
698 698
         } else {
699
-            return '<span class="dashicons dashicons-editor-help" title="' . esc_attr( $tip ) . '"></span>';
699
+            return '<span class="dashicons dashicons-editor-help" title="' . esc_attr($tip) . '"></span>';
700 700
         }
701 701
 }
702 702
 
703
-    if ( $echo ) {
704
-        echo '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . esc_attr( $tip ) . '"></span>';
703
+    if ($echo) {
704
+        echo '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . esc_attr($tip) . '"></span>';
705 705
     } else {
706
-        return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . esc_attr( $tip ) . '"></span>';
706
+        return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . esc_attr($tip) . '"></span>';
707 707
     }
708 708
 }
709 709
 
@@ -715,9 +715,9 @@  discard block
 block discarded – undo
715 715
  * @param string $var
716 716
  * @return string
717 717
  */
718
-function wpi_sanitize_tooltip( $var ) {
718
+function wpi_sanitize_tooltip($var) {
719 719
     return wp_kses(
720
-        html_entity_decode( $var ),
720
+        html_entity_decode($var),
721 721
         array(
722 722
 			'br'     => array(),
723 723
 			'em'     => array(),
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
  */
741 741
 function wpinv_get_screen_ids() {
742 742
 
743
-    $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) );
743
+    $screen_id = sanitize_title(__('Invoicing', 'invoicing'));
744 744
 
745 745
     $screen_ids = array(
746 746
         'toplevel_page_' . $screen_id,
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
         'gp-setup', // setup wizard
763 763
     );
764 764
 
765
-    return apply_filters( 'wpinv_screen_ids', $screen_ids );
765
+    return apply_filters('wpinv_screen_ids', $screen_ids);
766 766
 }
767 767
 
768 768
 /**
@@ -773,14 +773,14 @@  discard block
 block discarded – undo
773 773
  * @param array|string $list List of values.
774 774
  * @return array Sanitized array of values.
775 775
  */
776
-function wpinv_parse_list( $list ) {
776
+function wpinv_parse_list($list) {
777 777
 
778
-    if ( empty( $list ) ) {
778
+    if (empty($list)) {
779 779
         $list = array();
780 780
     }
781 781
 
782
-	if ( ! is_array( $list ) ) {
783
-		return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
782
+	if (!is_array($list)) {
783
+		return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY);
784 784
 	}
785 785
 
786 786
 	return $list;
@@ -794,8 +794,8 @@  discard block
 block discarded – undo
794 794
  * @param string $key Type of data to fetch.
795 795
  * @return mixed Fetched data.
796 796
  */
797
-function wpinv_get_data( $key ) {
798
-    return apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" );
797
+function wpinv_get_data($key) {
798
+    return apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php");
799 799
 }
800 800
 
801 801
 /**
@@ -807,10 +807,10 @@  discard block
 block discarded – undo
807 807
  * @param bool $first_empty Whether or not the first item in the list should be empty
808 808
  * @return mixed Fetched data.
809 809
  */
810
-function wpinv_maybe_add_empty_option( $options, $first_empty ) {
810
+function wpinv_maybe_add_empty_option($options, $first_empty) {
811 811
 
812
-    if ( ! empty( $options ) && $first_empty ) {
813
-        return array_merge( array( '' => '' ), $options );
812
+    if (!empty($options) && $first_empty) {
813
+        return array_merge(array('' => ''), $options);
814 814
     }
815 815
     return $options;
816 816
 
@@ -822,21 +822,21 @@  discard block
 block discarded – undo
822 822
  * @param mixed $var Data to sanitize.
823 823
  * @return string|array
824 824
  */
825
-function wpinv_clean( $var ) {
825
+function wpinv_clean($var) {
826 826
 
827
-	if ( is_array( $var ) ) {
828
-		return array_map( 'wpinv_clean', $var );
827
+	if (is_array($var)) {
828
+		return array_map('wpinv_clean', $var);
829 829
     }
830 830
 
831
-    if ( is_object( $var ) ) {
832
-		$object_vars = get_object_vars( $var );
833
-		foreach ( $object_vars as $property_name => $property_value ) {
834
-			$var->$property_name = wpinv_clean( $property_value );
831
+    if (is_object($var)) {
832
+		$object_vars = get_object_vars($var);
833
+		foreach ($object_vars as $property_name => $property_value) {
834
+			$var->$property_name = wpinv_clean($property_value);
835 835
         }
836 836
         return $var;
837 837
 	}
838 838
 
839
-    return is_string( $var ) ? sanitize_text_field( stripslashes( $var ) ) : $var;
839
+    return is_string($var) ? sanitize_text_field(stripslashes($var)) : $var;
840 840
 }
841 841
 
842 842
 /**
@@ -845,43 +845,43 @@  discard block
 block discarded – undo
845 845
  * @param string $str Data to convert.
846 846
  * @return string|array
847 847
  */
848
-function getpaid_convert_price_string_to_options( $str ) {
848
+function getpaid_convert_price_string_to_options($str) {
849 849
 
850
-	$raw_options = array_map( 'trim', explode( ',', $str ) );
851
-    $options     = array();
850
+	$raw_options = array_map('trim', explode(',', $str));
851
+    $options = array();
852 852
 
853
-    foreach ( $raw_options as $option ) {
853
+    foreach ($raw_options as $option) {
854 854
 
855
-        if ( '' == $option ) {
855
+        if ('' == $option) {
856 856
             continue;
857 857
         }
858 858
 
859
-        $option = array_map( 'trim', explode( '|', $option ) );
859
+        $option = array_map('trim', explode('|', $option));
860 860
 
861 861
         $price = null;
862 862
         $label = null;
863 863
 
864
-        if ( isset( $option[0] ) && '' != $option[0] ) {
865
-            $label  = $option[0];
864
+        if (isset($option[0]) && '' != $option[0]) {
865
+            $label = $option[0];
866 866
         }
867 867
 
868
-        if ( isset( $option[1] ) && '' != $option[1] ) {
868
+        if (isset($option[1]) && '' != $option[1]) {
869 869
             $price = $option[1];
870 870
         }
871 871
 
872
-        if ( ! isset( $price ) ) {
872
+        if (!isset($price)) {
873 873
             $price = $label;
874 874
         }
875 875
 
876
-        if ( ! isset( $price ) || ! is_numeric( $price ) ) {
876
+        if (!isset($price) || !is_numeric($price)) {
877 877
             continue;
878 878
         }
879 879
 
880
-        if ( ! isset( $label ) ) {
880
+        if (!isset($label)) {
881 881
             $label = $price;
882 882
         }
883 883
 
884
-        $options[ "$label|$price" ] = $label;
884
+        $options["$label|$price"] = $label;
885 885
     }
886 886
 
887 887
     return $options;
@@ -890,14 +890,14 @@  discard block
 block discarded – undo
890 890
 /**
891 891
  * Returns the help tip.
892 892
  */
893
-function getpaid_get_help_tip( $tip, $additional_classes = '', $echo = false ) {
893
+function getpaid_get_help_tip($tip, $additional_classes = '', $echo = false) {
894 894
     $classes = 'wpi-help-tip dashicons dashicons-editor-help ' . $additional_classes;
895
-    $tip     = esc_attr( $tip );
895
+    $tip     = esc_attr($tip);
896 896
 
897
-    if ( $echo ) {
898
-        echo '<span class="' . esc_attr( $classes ) . '" data-tip="' . esc_attr( $tip ) . '"></span>';
897
+    if ($echo) {
898
+        echo '<span class="' . esc_attr($classes) . '" data-tip="' . esc_attr($tip) . '"></span>';
899 899
     } else {
900
-        return '<span class="' . esc_attr( $classes ) . '" data-tip="' . esc_attr( $tip ) . '"></span>';
900
+        return '<span class="' . esc_attr($classes) . '" data-tip="' . esc_attr($tip) . '"></span>';
901 901
     }
902 902
 
903 903
 }
@@ -905,18 +905,18 @@  discard block
 block discarded – undo
905 905
 /**
906 906
  * Formats a date
907 907
  */
908
-function getpaid_format_date( $date, $with_time = false ) {
908
+function getpaid_format_date($date, $with_time = false) {
909 909
 
910
-    if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) {
910
+    if (empty($date) || $date == '0000-00-00 00:00:00') {
911 911
         return '';
912 912
     }
913 913
 
914 914
     $format = getpaid_date_format();
915 915
 
916
-    if ( $with_time ) {
916
+    if ($with_time) {
917 917
         $format .= ' ' . getpaid_time_format();
918 918
     }
919
-    return date_i18n( $format, strtotime( $date ) );
919
+    return date_i18n($format, strtotime($date));
920 920
 
921 921
 }
922 922
 
@@ -925,9 +925,9 @@  discard block
 block discarded – undo
925 925
  *
926 926
  * @return string
927 927
  */
928
-function getpaid_format_date_value( $date, $default = '&mdash;', $with_time = false ) {
929
-    $date = getpaid_format_date( $date, $with_time );
930
-    return empty( $date ) ? $default : $date;
928
+function getpaid_format_date_value($date, $default = '&mdash;', $with_time = false) {
929
+    $date = getpaid_format_date($date, $with_time);
930
+    return empty($date) ? $default : $date;
931 931
 }
932 932
 
933 933
 /**
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
  * @return string
937 937
  */
938 938
 function getpaid_date_format() {
939
-	return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
939
+	return apply_filters('getpaid_date_format', get_option('date_format'));
940 940
 }
941 941
 
942 942
 /**
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
  * @return string
946 946
  */
947 947
 function getpaid_time_format() {
948
-	return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
948
+	return apply_filters('getpaid_time_format', get_option('time_format'));
949 949
 }
950 950
 
951 951
 /**
@@ -955,16 +955,16 @@  discard block
 block discarded – undo
955 955
  * @param  integer $limit Limit size in characters.
956 956
  * @return string
957 957
  */
958
-function getpaid_limit_length( $string, $limit ) {
958
+function getpaid_limit_length($string, $limit) {
959 959
     $str_limit = $limit - 3;
960 960
 
961
-	if ( function_exists( 'mb_strimwidth' ) ) {
962
-		if ( mb_strlen( $string ) > $limit ) {
963
-			$string = mb_strimwidth( $string, 0, $str_limit ) . '...';
961
+	if (function_exists('mb_strimwidth')) {
962
+		if (mb_strlen($string) > $limit) {
963
+			$string = mb_strimwidth($string, 0, $str_limit) . '...';
964 964
 		}
965 965
 	} else {
966
-		if ( strlen( $string ) > $limit ) {
967
-			$string = substr( $string, 0, $str_limit ) . '...';
966
+		if (strlen($string) > $limit) {
967
+			$string = substr($string, 0, $str_limit) . '...';
968 968
 		}
969 969
 	}
970 970
     return $string;
@@ -978,7 +978,7 @@  discard block
 block discarded – undo
978 978
  * @since 1.0.19
979 979
  */
980 980
 function getpaid_api() {
981
-    return getpaid()->get( 'api' );
981
+    return getpaid()->get('api');
982 982
 }
983 983
 
984 984
 /**
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
  * @since 1.0.19
989 989
  */
990 990
 function getpaid_post_types() {
991
-    return getpaid()->get( 'post_types' );
991
+    return getpaid()->get('post_types');
992 992
 }
993 993
 
994 994
 /**
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
  * @since 1.0.19
999 999
  */
1000 1000
 function getpaid_session() {
1001
-    return getpaid()->get( 'session' );
1001
+    return getpaid()->get('session');
1002 1002
 }
1003 1003
 
1004 1004
 /**
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
  * @since 1.0.19
1009 1009
  */
1010 1010
 function getpaid_notes() {
1011
-    return getpaid()->get( 'notes' );
1011
+    return getpaid()->get('notes');
1012 1012
 }
1013 1013
 
1014 1014
 /**
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
  * @return GetPaid_Admin
1018 1018
  */
1019 1019
 function getpaid_admin() {
1020
-    return getpaid()->get( 'admin' );
1020
+    return getpaid()->get('admin');
1021 1021
 }
1022 1022
 
1023 1023
 /**
@@ -1027,8 +1027,8 @@  discard block
 block discarded – undo
1027 1027
  * @param string $base the base url
1028 1028
  * @return string
1029 1029
  */
1030
-function getpaid_get_authenticated_action_url( $action, $base = false ) {
1031
-    return wp_nonce_url( add_query_arg( 'getpaid-action', $action, $base ), 'getpaid-nonce', 'getpaid-nonce' );
1030
+function getpaid_get_authenticated_action_url($action, $base = false) {
1031
+    return wp_nonce_url(add_query_arg('getpaid-action', $action, $base), 'getpaid-nonce', 'getpaid-nonce');
1032 1032
 }
1033 1033
 
1034 1034
 /**
@@ -1036,11 +1036,11 @@  discard block
 block discarded – undo
1036 1036
  *
1037 1037
  * @return string
1038 1038
  */
1039
-function getpaid_get_post_type_label( $post_type, $plural = true ) {
1039
+function getpaid_get_post_type_label($post_type, $plural = true) {
1040 1040
 
1041
-    $post_type = get_post_type_object( $post_type );
1041
+    $post_type = get_post_type_object($post_type);
1042 1042
 
1043
-    if ( ! is_object( $post_type ) ) {
1043
+    if (!is_object($post_type)) {
1044 1044
         return null;
1045 1045
     }
1046 1046
 
@@ -1053,18 +1053,18 @@  discard block
 block discarded – undo
1053 1053
  *
1054 1054
  * @return mixed|null
1055 1055
  */
1056
-function getpaid_get_array_field( $array, $key, $secondary_key = null ) {
1056
+function getpaid_get_array_field($array, $key, $secondary_key = null) {
1057 1057
 
1058
-    if ( ! is_array( $array ) ) {
1058
+    if (!is_array($array)) {
1059 1059
         return null;
1060 1060
     }
1061 1061
 
1062
-    if ( ! empty( $secondary_key ) ) {
1063
-        $array = isset( $array[ $secondary_key ] ) ? $array[ $secondary_key ] : array();
1064
-        return getpaid_get_array_field( $array, $key );
1062
+    if (!empty($secondary_key)) {
1063
+        $array = isset($array[$secondary_key]) ? $array[$secondary_key] : array();
1064
+        return getpaid_get_array_field($array, $key);
1065 1065
     }
1066 1066
 
1067
-    return isset( $array[ $key ] ) ? $array[ $key ] : null;
1067
+    return isset($array[$key]) ? $array[$key] : null;
1068 1068
 
1069 1069
 }
1070 1070
 
@@ -1073,12 +1073,12 @@  discard block
 block discarded – undo
1073 1073
  *
1074 1074
  * @return array
1075 1075
  */
1076
-function getpaid_array_merge_if_empty( $args, $defaults ) {
1076
+function getpaid_array_merge_if_empty($args, $defaults) {
1077 1077
 
1078
-    foreach ( $defaults as $key => $value ) {
1078
+    foreach ($defaults as $key => $value) {
1079 1079
 
1080
-        if ( empty( $args[ $key ] ) ) {
1081
-            $args[ $key ] = $value;
1080
+        if (empty($args[$key])) {
1081
+            $args[$key] = $value;
1082 1082
         }
1083 1083
     }
1084 1084
 
@@ -1095,12 +1095,12 @@  discard block
 block discarded – undo
1095 1095
 
1096 1096
     $types = get_allowed_mime_types();
1097 1097
 
1098
-    if ( isset( $types['htm|html'] ) ) {
1099
-		unset( $types['htm|html'] );
1098
+    if (isset($types['htm|html'])) {
1099
+		unset($types['htm|html']);
1100 1100
 	}
1101 1101
 
1102
-    if ( isset( $types['js'] ) ) {
1103
-		unset( $types['js'] );
1102
+    if (isset($types['js'])) {
1103
+		unset($types['js']);
1104 1104
 	}
1105 1105
 
1106 1106
     return $types;
@@ -1108,21 +1108,21 @@  discard block
 block discarded – undo
1108 1108
 }
1109 1109
 
1110 1110
 
1111
-function getpaid_user_delete_invoice( $data ) {
1111
+function getpaid_user_delete_invoice($data) {
1112 1112
 
1113 1113
     // Ensure there is an invoice to delete.
1114
-    if ( empty( $data['invoice_id'] ) ) {
1114
+    if (empty($data['invoice_id'])) {
1115 1115
         return;
1116 1116
     }
1117 1117
 
1118
-    $invoice = new WPInv_Invoice( (int) $data['invoice_id'] );
1118
+    $invoice = new WPInv_Invoice((int) $data['invoice_id']);
1119 1119
 
1120 1120
     // Ensure that it exists and that it belongs to the current user.
1121
-    if ( ! $invoice->exists() || $invoice->get_customer_id() != get_current_user_id() ) {
1121
+    if (!$invoice->exists() || $invoice->get_customer_id() != get_current_user_id()) {
1122 1122
         $notice = 'perm_delete_invoice';
1123 1123
 
1124 1124
     // Can it be deleted?
1125
-    } elseif ( ! $invoice->needs_payment() ) {
1125
+    } elseif (!$invoice->needs_payment()) {
1126 1126
         $notice = 'cannot_delete_invoice';
1127 1127
 
1128 1128
     // Delete it.
@@ -1141,11 +1141,11 @@  discard block
 block discarded – undo
1141 1141
         )
1142 1142
     );
1143 1143
 
1144
-    wp_safe_redirect( $redirect );
1144
+    wp_safe_redirect($redirect);
1145 1145
     exit;
1146 1146
 
1147 1147
 }
1148
-add_action( 'getpaid_authenticated_action_delete_invoice', 'getpaid_user_delete_invoice' );
1148
+add_action('getpaid_authenticated_action_delete_invoice', 'getpaid_user_delete_invoice');
1149 1149
 
1150 1150
 /**
1151 1151
  * Converts string to lower case.
@@ -1156,11 +1156,11 @@  discard block
 block discarded – undo
1156 1156
  * @param string $charset Character set to use for conversion.
1157 1157
  * @return string Returns converted string.
1158 1158
  */
1159
-function getpaid_strtolower( $string, $charset = 'UTF-8' ) {
1160
-	if ( function_exists( 'mb_convert_case' ) ) {
1161
-		return mb_convert_case( $string, MB_CASE_LOWER, $charset );
1159
+function getpaid_strtolower($string, $charset = 'UTF-8') {
1160
+	if (function_exists('mb_convert_case')) {
1161
+		return mb_convert_case($string, MB_CASE_LOWER, $charset);
1162 1162
 	} else {
1163
-		return strtolower( $string );
1163
+		return strtolower($string);
1164 1164
 	}
1165 1165
 }
1166 1166
 
@@ -1173,10 +1173,10 @@  discard block
 block discarded – undo
1173 1173
  * @param string $charset Character set to use for conversion.
1174 1174
  * @return string Returns converted string.
1175 1175
  */
1176
-function getpaid_strtoupper( $string, $charset = 'UTF-8' ) {
1177
-	if ( function_exists( 'mb_convert_case' ) ) {
1178
-		return mb_convert_case( $string, MB_CASE_UPPER, $charset );
1176
+function getpaid_strtoupper($string, $charset = 'UTF-8') {
1177
+	if (function_exists('mb_convert_case')) {
1178
+		return mb_convert_case($string, MB_CASE_UPPER, $charset);
1179 1179
 	} else {
1180
-		return strtoupper( $string );
1180
+		return strtoupper($string);
1181 1181
 	}
1182 1182
 }
1183 1183
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/views/wizard-thank-you.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -4,40 +4,40 @@
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 global $aui_bs5;
10 10
 ?>
11 11
 <div class="card shadow-sm my-5">
12 12
 	<div class="text-center card-body">
13
-		<h1 class="h3"><?php esc_html_e( 'Awesome, you are ready to Get Paid', 'invoicing' ); ?></h1>
13
+		<h1 class="h3"><?php esc_html_e('Awesome, you are ready to Get Paid', 'invoicing'); ?></h1>
14 14
 
15 15
 		<div class="geodirectory-message geodirectory-tracker">
16
-			<p><?php esc_html_e( 'Thank you for choosing GetPaid!', 'invoicing' ); ?> <i class="far fa-smile-beam"></i></p>
16
+			<p><?php esc_html_e('Thank you for choosing GetPaid!', 'invoicing'); ?> <i class="far fa-smile-beam"></i></p>
17 17
 		</div>
18 18
 
19 19
 		<div class="gp-setup-next-steps">
20 20
 			<div class="gp-setup-next-steps-first mb-4">
21 21
 				<div>
22
-					<h2 class="h3"><i class="fas fa-arrow-down"></i> <?php esc_html_e( 'Watch This', 'invoicing' ); ?> <i class="fas fa-arrow-down"></i></h2>
23
-					<div class="<?php echo( $aui_bs5 ? 'ratio ratio-16x9' : 'embed-responsive embed-responsive-16by9' ); ?> mb-4">
24
-						<iframe class="<?php echo( $aui_bs5 ? '' : 'embed-responsive-item' ); ?>" src="https://www.youtube.com/embed/TXZuPXHjt9E?rel=0" allowfullscreen></iframe>
22
+					<h2 class="h3"><i class="fas fa-arrow-down"></i> <?php esc_html_e('Watch This', 'invoicing'); ?> <i class="fas fa-arrow-down"></i></h2>
23
+					<div class="<?php echo($aui_bs5 ? 'ratio ratio-16x9' : 'embed-responsive embed-responsive-16by9'); ?> mb-4">
24
+						<iframe class="<?php echo($aui_bs5 ? '' : 'embed-responsive-item'); ?>" src="https://www.youtube.com/embed/TXZuPXHjt9E?rel=0" allowfullscreen></iframe>
25 25
 					</div>
26 26
 				</div>
27
-				<h2 class="h3"><?php esc_html_e( 'Next steps', 'invoicing' ); ?></h2>
27
+				<h2 class="h3"><?php esc_html_e('Next steps', 'invoicing'); ?></h2>
28 28
 
29 29
 				<div class="d-flex justify-content-between">
30
-					<a class="btn btn-outline-primary btn-sm" href="<?php echo esc_url( admin_url( 'post-new.php?post_type=wpi_item' ) ); ?>"><span class="h1 d-block"><i class="fas fa-box-open"></i></span> <?php esc_html_e( 'Create Item', 'invoicing' ); ?></a>
31
-					<a class="btn btn-outline-primary btn-sm" href="<?php echo esc_url( admin_url( 'post-new.php?post_type=wpi_payment_form' ) ); ?>"><span class="h1 d-block"><i class="fas fa-align-justify"></i></span> <?php esc_html_e( 'Create Payment Form', 'invoicing' ); ?></a>
32
-					<a class="btn btn-outline-primary btn-sm" href="<?php echo esc_url( admin_url( 'post-new.php?post_type=wpi_invoice' ) ); ?>"><span class="h1 d-block"><i class="fas fa-file-alt"></i></span> <?php esc_html_e( 'Create Invoice', 'invoicing' ); ?></a>
30
+					<a class="btn btn-outline-primary btn-sm" href="<?php echo esc_url(admin_url('post-new.php?post_type=wpi_item')); ?>"><span class="h1 d-block"><i class="fas fa-box-open"></i></span> <?php esc_html_e('Create Item', 'invoicing'); ?></a>
31
+					<a class="btn btn-outline-primary btn-sm" href="<?php echo esc_url(admin_url('post-new.php?post_type=wpi_payment_form')); ?>"><span class="h1 d-block"><i class="fas fa-align-justify"></i></span> <?php esc_html_e('Create Payment Form', 'invoicing'); ?></a>
32
+					<a class="btn btn-outline-primary btn-sm" href="<?php echo esc_url(admin_url('post-new.php?post_type=wpi_invoice')); ?>"><span class="h1 d-block"><i class="fas fa-file-alt"></i></span> <?php esc_html_e('Create Invoice', 'invoicing'); ?></a>
33 33
 				</div>
34 34
 
35
-				<h2 class="h3 mt-4"><?php esc_html_e( 'Learn more', 'invoicing' ); ?></h2>
35
+				<h2 class="h3 mt-4"><?php esc_html_e('Learn more', 'invoicing'); ?></h2>
36 36
 				<div class="gp-setup-next-steps-last mt-2 d-flex justify-content-between">
37
-					<a class="btn btn-outline-primary btn-sm" href="https://docs.wpgetpaid.com/collection/114-getting-started?utm_source=setupwizard&utm_medium=product&utm_content=getting-started&utm_campaign=invoicingplugin" target="_blank"><?php esc_html_e( 'Getting Started', 'invoicing' ); ?></a>
38
-					<a class="btn btn-outline-primary btn-sm" href="https://docs.wpgetpaid.com/?utm_source=setupwizard&utm_medium=product&utm_content=docs&utm_campaign=invoicingplugin" target="_blank"><?php esc_html_e( 'Documentation', 'invoicing' ); ?></a>
39
-					<a class="btn btn-outline-primary btn-sm" href="https://wpgetpaid.com/support/?utm_source=setupwizard&utm_medium=product&utm_content=docs&utm_campaign=invoicingyplugin" target="_blank"><?php esc_html_e( 'Support', 'invoicing' ); ?></a>
40
-					<a class="btn btn-outline-primary btn-sm" href="https://demos.ayecode.io/getpaid/?utm_source=setupwizard&utm_medium=product&utm_content=demos&utm_campaign=invoicingyplugin" target="_blank"><?php esc_html_e( 'Demos', 'invoicing' ); ?></a>
37
+					<a class="btn btn-outline-primary btn-sm" href="https://docs.wpgetpaid.com/collection/114-getting-started?utm_source=setupwizard&utm_medium=product&utm_content=getting-started&utm_campaign=invoicingplugin" target="_blank"><?php esc_html_e('Getting Started', 'invoicing'); ?></a>
38
+					<a class="btn btn-outline-primary btn-sm" href="https://docs.wpgetpaid.com/?utm_source=setupwizard&utm_medium=product&utm_content=docs&utm_campaign=invoicingplugin" target="_blank"><?php esc_html_e('Documentation', 'invoicing'); ?></a>
39
+					<a class="btn btn-outline-primary btn-sm" href="https://wpgetpaid.com/support/?utm_source=setupwizard&utm_medium=product&utm_content=docs&utm_campaign=invoicingyplugin" target="_blank"><?php esc_html_e('Support', 'invoicing'); ?></a>
40
+					<a class="btn btn-outline-primary btn-sm" href="https://demos.ayecode.io/getpaid/?utm_source=setupwizard&utm_medium=product&utm_content=demos&utm_campaign=invoicingyplugin" target="_blank"><?php esc_html_e('Demos', 'invoicing'); ?></a>
41 41
 				</div>
42 42
 			</div>
43 43
 		</div>
Please login to merge, or discard this patch.
includes/admin/views/wizard-plugins.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -4,31 +4,31 @@
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 global $aui_bs5;
10 10
 ?>
11 11
 <div class="card shadow-sm my-5">
12
-	<form method="post" class="text-center card-body" action="<?php echo esc_url( admin_url() ); ?>">
13
-		<?php getpaid_hidden_field( 'getpaid-admin-action', 'install_plugin' ); ?>
14
-		<?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?>
15
-		<?php getpaid_hidden_field( 'redirect', $next_url ); ?>
12
+	<form method="post" class="text-center card-body" action="<?php echo esc_url(admin_url()); ?>">
13
+		<?php getpaid_hidden_field('getpaid-admin-action', 'install_plugin'); ?>
14
+		<?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?>
15
+		<?php getpaid_hidden_field('redirect', $next_url); ?>
16 16
 		<div class="gd-wizard-recommend">
17
-			<h2 class="gd-settings-title h3"><?php esc_html_e( 'Recommended Plugins', 'invoicing' ); ?></h2>
18
-			<p><?php esc_html_e( 'Below are a few of our own plugins that may help you.', 'invoicing' ); ?></p>
17
+			<h2 class="gd-settings-title h3"><?php esc_html_e('Recommended Plugins', 'invoicing'); ?></h2>
18
+			<p><?php esc_html_e('Below are a few of our own plugins that may help you.', 'invoicing'); ?></p>
19 19
 			<ul class="list-group">
20
-				<?php foreach ( $recommended_plugins as $key => $plugin ) : ?>
21
-				<li class="list-group-item d-flex justify-content-between align-items-center flex-wrap <?php echo( $aui_bs5 ? 'text-start' : 'text-left' ); ?>">
22
-					<span class="mr-auto"><?php echo esc_html( $plugin['name'] ); ?></span>
23
-					<div class="<?php echo( $aui_bs5 ? 'form-check form-switch me-n2' : 'custom-control custom-switch mr-n2 getpaid-install-plugin-siwtch-div' ); ?>">
24
-						<input type="checkbox" name="plugins[<?php echo esc_attr( $plugin['slug'] ); ?>]" value="<?php echo esc_attr( $plugin['file'] ); ?>" class="<?php echo ( $aui_bs5 ? 'form-check-input' : 'custom-control-input' ); ?>" <?php if ( is_plugin_active( $plugin['file'] ) ) { echo 'checked';}?> id="ac-setting-updates<?php echo esc_attr( $key ); ?>">
25
-						<label class="<?php echo ( $aui_bs5 ? 'form-check-label' : 'custom-control-label' ); ?>" for="ac-setting-updates<?php echo esc_attr( $key ); ?>"></label>
20
+				<?php foreach ($recommended_plugins as $key => $plugin) : ?>
21
+				<li class="list-group-item d-flex justify-content-between align-items-center flex-wrap <?php echo($aui_bs5 ? 'text-start' : 'text-left'); ?>">
22
+					<span class="mr-auto"><?php echo esc_html($plugin['name']); ?></span>
23
+					<div class="<?php echo($aui_bs5 ? 'form-check form-switch me-n2' : 'custom-control custom-switch mr-n2 getpaid-install-plugin-siwtch-div'); ?>">
24
+						<input type="checkbox" name="plugins[<?php echo esc_attr($plugin['slug']); ?>]" value="<?php echo esc_attr($plugin['file']); ?>" class="<?php echo ($aui_bs5 ? 'form-check-input' : 'custom-control-input'); ?>" <?php if (is_plugin_active($plugin['file'])) { echo 'checked'; }?> id="ac-setting-updates<?php echo esc_attr($key); ?>">
25
+						<label class="<?php echo ($aui_bs5 ? 'form-check-label' : 'custom-control-label'); ?>" for="ac-setting-updates<?php echo esc_attr($key); ?>"></label>
26 26
 					</div>
27
-					<small class="w-100"><?php echo esc_attr( $plugin['desc'] ); ?></small>
27
+					<small class="w-100"><?php echo esc_attr($plugin['desc']); ?></small>
28 28
 				</li>
29 29
 				<?php endforeach; ?>
30 30
 			</ul>
31
-			<p class="gp-setup-actions step text-center mt-4"><input type="submit" class="btn btn-primary button-next" value="<?php esc_attr_e( 'Continue', 'invoicing' ); ?>" name="save_step"/></p>
31
+			<p class="gp-setup-actions step text-center mt-4"><input type="submit" class="btn btn-primary button-next" value="<?php esc_attr_e('Continue', 'invoicing'); ?>" name="save_step"/></p>
32 32
 		</div>
33 33
 	</form>
34 34
 </div>
35 35
\ No newline at end of file
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-paypal-api.php 2 patches
Indentation   +214 added lines, -214 removed lines patch added patch discarded remove patch
@@ -10,227 +10,227 @@
 block discarded – undo
10 10
  */
11 11
 class GetPaid_PayPal_API {
12 12
 
13
-	/**
14
-	 * Retrieves the bearer token.
15
-	 *
13
+    /**
14
+     * Retrieves the bearer token.
15
+     *
16 16
      * @return string|\WP_Error
17
-	 */
18
-	public static function get_token( $mode = 'live' ) {
17
+     */
18
+    public static function get_token( $mode = 'live' ) {
19 19
 
20
-		$token = get_transient( 'getpaid_paypal_' . $mode . '_token' );
20
+        $token = get_transient( 'getpaid_paypal_' . $mode . '_token' );
21 21
 
22
-		if ( $token ) {
23
-			return $token;
24
-		}
22
+        if ( $token ) {
23
+            return $token;
24
+        }
25 25
 
26
-		$client_id  = 'live' === $mode ? wpinv_get_option( 'paypal_client_id' ) : wpinv_get_option( 'paypal_sandbox_client_id' );
27
-		$secret_key = 'live' === $mode ? wpinv_get_option( 'paypal_secret' ) : wpinv_get_option( 'paypal_sandbox_secret' );
28
-		$url        = self::get_api_url( 'v1/oauth2/token?grant_type=client_credentials', $mode );
26
+        $client_id  = 'live' === $mode ? wpinv_get_option( 'paypal_client_id' ) : wpinv_get_option( 'paypal_sandbox_client_id' );
27
+        $secret_key = 'live' === $mode ? wpinv_get_option( 'paypal_secret' ) : wpinv_get_option( 'paypal_sandbox_secret' );
28
+        $url        = self::get_api_url( 'v1/oauth2/token?grant_type=client_credentials', $mode );
29 29
 
30 30
         if ( empty( $client_id ) || empty( $secret_key ) ) {
31 31
             return new \WP_Error( 'invalid_request', 'Missing client id or secret key.', array( 'status' => 400 ) );
32 32
         }
33 33
 
34
-		$args   = array(
35
-			'method'  => 'POST',
36
-			'timeout' => 30,
37
-			'headers' => array(
38
-				'Authorization' => 'Basic ' . base64_encode( $client_id . ':' . $secret_key ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
39
-				'Accept'        => 'application/json',
40
-				'Content-Type'  => 'application/x-www-form-urlencoded',
41
-			),
42
-		);
43
-
44
-		$response = self::response_or_error( wp_remote_post( $url, $args ) );
45
-
46
-		if ( is_wp_error( $response ) ) {
47
-			return $response;
48
-		}
49
-
50
-		if ( ! isset( $response->access_token ) ) {
51
-			return new \WP_Error( 'invalid_request', 'Could not create token.', array( 'status' => 400 ) );
52
-		}
53
-
54
-		set_transient( 'getpaid_paypal_' . $mode . '_token', $response->access_token, $response->expires_in - 600 );
55
-		return $response->access_token;
56
-	}
57
-
58
-	/**
59
-	 * Retrieves the PayPal API URL.
60
-	 *
61
-	 * @param string $endpoint
62
-	 * @return string
63
-	 */
64
-	public static function get_api_url( $endpoint = '', $mode = 'live'  ) {
65
-		$endpoint = ltrim( $endpoint, '/' );
66
-		return 'live' === $mode ? 'https://api-m.paypal.com/' . $endpoint : 'https://api-m.sandbox.paypal.com/' . $endpoint;
67
-	}
68
-
69
-	/**
70
-	 * Handles a post request.
71
-	 *
72
-	 * @param string $path The path to the endpoint.
73
-	 * @param mixed $data The data to send.
74
-	 * @param string $method The method to use.
75
-	 *
76
-	 * @return true|\WP_Error
77
-	 */
78
-	public static function post( $path, $data, $mode = 'live', $method = 'POST' ) {
79
-
80
-		$access_token = self::get_token( $mode );
81
-
82
-		if ( is_wp_error( $access_token ) ) {
83
-			return $access_token;
84
-		}
85
-
86
-		$url  = self::get_api_url( $path, $mode );
87
-		$args = array(
88
-			'method'  => $method,
89
-			'headers' => array(
90
-				'Authorization' => 'Bearer ' . $access_token,
91
-				'Content-Type'  => 'application/json',
92
-			),
93
-		);
94
-
95
-		if( ! empty( $data )) {
96
-			$args['body'] = wp_json_encode( $data );
97
-		}
98
-
99
-		return self::response_or_error( wp_remote_post( $url, $args ) );
100
-	}
101
-
102
-	/**
103
-	 * Handles a get request.
104
-	 *
105
-	 * @param string $path The path to the endpoint.
106
-	 * @param string $method
107
-	 * @return object|\WP_Error
108
-	 */
109
-	public static function get( $path, $mode = 'live', $method = 'GET' ) {
110
-
111
-		$access_token = self::get_token( $mode );
112
-
113
-		if ( is_wp_error( $access_token ) ) {
114
-			return $access_token;
115
-		}
116
-
117
-		$url  = self::get_api_url( $path, $mode );
118
-		$args = array(
119
-			'method'  => $method,
120
-			'headers' => array(
121
-				'Authorization' => 'Bearer ' . $access_token,
122
-			),
123
-		);
124
-
125
-		return self::response_or_error( wp_remote_get( $url, $args ) );
126
-	}
127
-
128
-	/**
129
-	 * Returns the response body
130
-	 *
131
-	 * @since 1.0.0
132
-	 * @version 1.0.0
133
-	 * @param \WP_Error|array $response
134
-	 * @return \WP_Error|object
135
-	 */
136
-	public static function response_or_error( $response ) {
137
-
138
-		if ( is_wp_error( $response ) ) {
139
-			return new \WP_Error( 'paypal_error', __( 'There was a problem connecting to the PayPal API endpoint.', 'invoicing' ) );
140
-		}
141
-
142
-		if ( empty( $response['body'] ) ) {
143
-			return true;
144
-		}
145
-
146
-		$response_body = json_decode( wp_remote_retrieve_body( $response ) );
147
-
148
-		if ( wp_remote_retrieve_response_code( $response ) > 299 ) {
149
-
150
-			// Normal errors.
151
-			if ( $response_body && isset( $response_body->message ) ) {
152
-				$error_message = $response_body->message;
153
-
154
-			// Identity errors.
155
-			} elseif ( $response_body && isset( $response_body->error_description ) ) {
156
-				$error_message = $response_body->error_description;
157
-				return new \WP_Error( 'paypal_error', wp_kses_post( $response_body->error_description ) );
158
-			} else {
159
-				$error_message = __( 'There was an error connecting to the PayPal API endpoint.', 'invoicing' );
160
-			}
161
-
162
-			return new \WP_Error( 'paypal_error', $error_message );
163
-		}
164
-
165
-		return $response_body;
166
-	}
167
-
168
-	/**
169
-	 * Fetches an order.
170
-	 *
171
-	 * @since 1.0.0
172
-	 * @version 1.0.0
173
-	 * @param string $order_id
174
-	 * @link https://developer.paypal.com/docs/api/orders/v2/#orders_get
175
-	 * @return \WP_Error|object
176
-	 */
177
-	public static function get_order( $order_id, $mode = 'live' ) {
178
-		return self::get( '/v2/checkout/orders/' . $order_id, $mode );
179
-	}
180
-
181
-	/**
182
-	 * Fetches a subscription.
183
-	 *
184
-	 * @since 1.0.0
185
-	 * @version 1.0.0
186
-	 * @param string $subscription_id
187
-	 * @link https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_get
188
-	 * @return \WP_Error|object
189
-	 */
190
-	public static function get_subscription( $subscription_id, $mode = 'live' ) {
191
-		return self::get( '/v1/billing/subscriptions/' . $subscription_id, $mode );
192
-	}
193
-
194
-	/**
195
-	 * Fetches a subscription's latest transactions (limits search to last one day).
196
-	 *
197
-	 * @since 1.0.0
198
-	 * @version 1.0.0
199
-	 * @param string $subscription_id
200
-	 * @link https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_transactions
201
-	 * @return \WP_Error|object
202
-	 */
203
-	public static function get_subscription_transaction( $subscription_id, $mode = 'live' ) {
204
-		$start_time = gmdate( 'Y-m-d\TH:i:s\Z', strtotime( '-1 day' ) );
205
-		$end_time   = gmdate( 'Y-m-d\TH:i:s\Z' );
206
-		return self::get( "/v1/billing/subscriptions/$subscription_id/transactions?start_time=$start_time&end_time=$end_time", $mode );
207
-	}
208
-
209
-	/**
210
-	 * Refunds a capture.
211
-	 *
212
-	 * @since 1.0.0
213
-	 * @version 1.0.0
214
-	 * @param string $capture_id
215
-	 * @param array  $args
216
-	 * @link https://developer.paypal.com/docs/api/payments/v2/#captures_refund
217
-	 * @return \WP_Error|object
218
-	 */
219
-	public static function refund_capture( $capture_id, $args = array(), $mode = 'live' ) {
220
-		return self::post( '/v2/payments/captures/' . $capture_id . '/refund', $args, $mode );
221
-	}
222
-
223
-	/**
224
-	 * Cancels a subscription.
225
-	 *
226
-	 * @since 2.8.24
227
-	 * @version 2.8.24
228
-	 * @param string $subscription_id
229
-	 * @param array  $args
230
-	 * @link https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_cancel
231
-	 * @return \WP_Error|object
232
-	 */
233
-	public static function cancel_subscription( $subscription_id, $args = array(), $mode = 'live' ) {
234
-		return self::post( '/v1/billing/subscriptions/' . $subscription_id . '/cancel', $args, $mode );
235
-	}
34
+        $args   = array(
35
+            'method'  => 'POST',
36
+            'timeout' => 30,
37
+            'headers' => array(
38
+                'Authorization' => 'Basic ' . base64_encode( $client_id . ':' . $secret_key ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
39
+                'Accept'        => 'application/json',
40
+                'Content-Type'  => 'application/x-www-form-urlencoded',
41
+            ),
42
+        );
43
+
44
+        $response = self::response_or_error( wp_remote_post( $url, $args ) );
45
+
46
+        if ( is_wp_error( $response ) ) {
47
+            return $response;
48
+        }
49
+
50
+        if ( ! isset( $response->access_token ) ) {
51
+            return new \WP_Error( 'invalid_request', 'Could not create token.', array( 'status' => 400 ) );
52
+        }
53
+
54
+        set_transient( 'getpaid_paypal_' . $mode . '_token', $response->access_token, $response->expires_in - 600 );
55
+        return $response->access_token;
56
+    }
57
+
58
+    /**
59
+     * Retrieves the PayPal API URL.
60
+     *
61
+     * @param string $endpoint
62
+     * @return string
63
+     */
64
+    public static function get_api_url( $endpoint = '', $mode = 'live'  ) {
65
+        $endpoint = ltrim( $endpoint, '/' );
66
+        return 'live' === $mode ? 'https://api-m.paypal.com/' . $endpoint : 'https://api-m.sandbox.paypal.com/' . $endpoint;
67
+    }
68
+
69
+    /**
70
+     * Handles a post request.
71
+     *
72
+     * @param string $path The path to the endpoint.
73
+     * @param mixed $data The data to send.
74
+     * @param string $method The method to use.
75
+     *
76
+     * @return true|\WP_Error
77
+     */
78
+    public static function post( $path, $data, $mode = 'live', $method = 'POST' ) {
79
+
80
+        $access_token = self::get_token( $mode );
81
+
82
+        if ( is_wp_error( $access_token ) ) {
83
+            return $access_token;
84
+        }
85
+
86
+        $url  = self::get_api_url( $path, $mode );
87
+        $args = array(
88
+            'method'  => $method,
89
+            'headers' => array(
90
+                'Authorization' => 'Bearer ' . $access_token,
91
+                'Content-Type'  => 'application/json',
92
+            ),
93
+        );
94
+
95
+        if( ! empty( $data )) {
96
+            $args['body'] = wp_json_encode( $data );
97
+        }
98
+
99
+        return self::response_or_error( wp_remote_post( $url, $args ) );
100
+    }
101
+
102
+    /**
103
+     * Handles a get request.
104
+     *
105
+     * @param string $path The path to the endpoint.
106
+     * @param string $method
107
+     * @return object|\WP_Error
108
+     */
109
+    public static function get( $path, $mode = 'live', $method = 'GET' ) {
110
+
111
+        $access_token = self::get_token( $mode );
112
+
113
+        if ( is_wp_error( $access_token ) ) {
114
+            return $access_token;
115
+        }
116
+
117
+        $url  = self::get_api_url( $path, $mode );
118
+        $args = array(
119
+            'method'  => $method,
120
+            'headers' => array(
121
+                'Authorization' => 'Bearer ' . $access_token,
122
+            ),
123
+        );
124
+
125
+        return self::response_or_error( wp_remote_get( $url, $args ) );
126
+    }
127
+
128
+    /**
129
+     * Returns the response body
130
+     *
131
+     * @since 1.0.0
132
+     * @version 1.0.0
133
+     * @param \WP_Error|array $response
134
+     * @return \WP_Error|object
135
+     */
136
+    public static function response_or_error( $response ) {
137
+
138
+        if ( is_wp_error( $response ) ) {
139
+            return new \WP_Error( 'paypal_error', __( 'There was a problem connecting to the PayPal API endpoint.', 'invoicing' ) );
140
+        }
141
+
142
+        if ( empty( $response['body'] ) ) {
143
+            return true;
144
+        }
145
+
146
+        $response_body = json_decode( wp_remote_retrieve_body( $response ) );
147
+
148
+        if ( wp_remote_retrieve_response_code( $response ) > 299 ) {
149
+
150
+            // Normal errors.
151
+            if ( $response_body && isset( $response_body->message ) ) {
152
+                $error_message = $response_body->message;
153
+
154
+            // Identity errors.
155
+            } elseif ( $response_body && isset( $response_body->error_description ) ) {
156
+                $error_message = $response_body->error_description;
157
+                return new \WP_Error( 'paypal_error', wp_kses_post( $response_body->error_description ) );
158
+            } else {
159
+                $error_message = __( 'There was an error connecting to the PayPal API endpoint.', 'invoicing' );
160
+            }
161
+
162
+            return new \WP_Error( 'paypal_error', $error_message );
163
+        }
164
+
165
+        return $response_body;
166
+    }
167
+
168
+    /**
169
+     * Fetches an order.
170
+     *
171
+     * @since 1.0.0
172
+     * @version 1.0.0
173
+     * @param string $order_id
174
+     * @link https://developer.paypal.com/docs/api/orders/v2/#orders_get
175
+     * @return \WP_Error|object
176
+     */
177
+    public static function get_order( $order_id, $mode = 'live' ) {
178
+        return self::get( '/v2/checkout/orders/' . $order_id, $mode );
179
+    }
180
+
181
+    /**
182
+     * Fetches a subscription.
183
+     *
184
+     * @since 1.0.0
185
+     * @version 1.0.0
186
+     * @param string $subscription_id
187
+     * @link https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_get
188
+     * @return \WP_Error|object
189
+     */
190
+    public static function get_subscription( $subscription_id, $mode = 'live' ) {
191
+        return self::get( '/v1/billing/subscriptions/' . $subscription_id, $mode );
192
+    }
193
+
194
+    /**
195
+     * Fetches a subscription's latest transactions (limits search to last one day).
196
+     *
197
+     * @since 1.0.0
198
+     * @version 1.0.0
199
+     * @param string $subscription_id
200
+     * @link https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_transactions
201
+     * @return \WP_Error|object
202
+     */
203
+    public static function get_subscription_transaction( $subscription_id, $mode = 'live' ) {
204
+        $start_time = gmdate( 'Y-m-d\TH:i:s\Z', strtotime( '-1 day' ) );
205
+        $end_time   = gmdate( 'Y-m-d\TH:i:s\Z' );
206
+        return self::get( "/v1/billing/subscriptions/$subscription_id/transactions?start_time=$start_time&end_time=$end_time", $mode );
207
+    }
208
+
209
+    /**
210
+     * Refunds a capture.
211
+     *
212
+     * @since 1.0.0
213
+     * @version 1.0.0
214
+     * @param string $capture_id
215
+     * @param array  $args
216
+     * @link https://developer.paypal.com/docs/api/payments/v2/#captures_refund
217
+     * @return \WP_Error|object
218
+     */
219
+    public static function refund_capture( $capture_id, $args = array(), $mode = 'live' ) {
220
+        return self::post( '/v2/payments/captures/' . $capture_id . '/refund', $args, $mode );
221
+    }
222
+
223
+    /**
224
+     * Cancels a subscription.
225
+     *
226
+     * @since 2.8.24
227
+     * @version 2.8.24
228
+     * @param string $subscription_id
229
+     * @param array  $args
230
+     * @link https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_cancel
231
+     * @return \WP_Error|object
232
+     */
233
+    public static function cancel_subscription( $subscription_id, $args = array(), $mode = 'live' ) {
234
+        return self::post( '/v1/billing/subscriptions/' . $subscription_id . '/cancel', $args, $mode );
235
+    }
236 236
 }
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 // Exit if accessed directly.
4
-defined( 'ABSPATH' ) || exit;
4
+defined('ABSPATH') || exit;
5 5
 
6 6
 /**
7 7
  * PayPal API handler.
@@ -15,43 +15,43 @@  discard block
 block discarded – undo
15 15
 	 *
16 16
      * @return string|\WP_Error
17 17
 	 */
18
-	public static function get_token( $mode = 'live' ) {
18
+	public static function get_token($mode = 'live') {
19 19
 
20
-		$token = get_transient( 'getpaid_paypal_' . $mode . '_token' );
20
+		$token = get_transient('getpaid_paypal_' . $mode . '_token');
21 21
 
22
-		if ( $token ) {
22
+		if ($token) {
23 23
 			return $token;
24 24
 		}
25 25
 
26
-		$client_id  = 'live' === $mode ? wpinv_get_option( 'paypal_client_id' ) : wpinv_get_option( 'paypal_sandbox_client_id' );
27
-		$secret_key = 'live' === $mode ? wpinv_get_option( 'paypal_secret' ) : wpinv_get_option( 'paypal_sandbox_secret' );
28
-		$url        = self::get_api_url( 'v1/oauth2/token?grant_type=client_credentials', $mode );
26
+		$client_id  = 'live' === $mode ? wpinv_get_option('paypal_client_id') : wpinv_get_option('paypal_sandbox_client_id');
27
+		$secret_key = 'live' === $mode ? wpinv_get_option('paypal_secret') : wpinv_get_option('paypal_sandbox_secret');
28
+		$url        = self::get_api_url('v1/oauth2/token?grant_type=client_credentials', $mode);
29 29
 
30
-        if ( empty( $client_id ) || empty( $secret_key ) ) {
31
-            return new \WP_Error( 'invalid_request', 'Missing client id or secret key.', array( 'status' => 400 ) );
30
+        if (empty($client_id) || empty($secret_key)) {
31
+            return new \WP_Error('invalid_request', 'Missing client id or secret key.', array('status' => 400));
32 32
         }
33 33
 
34
-		$args   = array(
34
+		$args = array(
35 35
 			'method'  => 'POST',
36 36
 			'timeout' => 30,
37 37
 			'headers' => array(
38
-				'Authorization' => 'Basic ' . base64_encode( $client_id . ':' . $secret_key ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
38
+				'Authorization' => 'Basic ' . base64_encode($client_id . ':' . $secret_key), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode
39 39
 				'Accept'        => 'application/json',
40 40
 				'Content-Type'  => 'application/x-www-form-urlencoded',
41 41
 			),
42 42
 		);
43 43
 
44
-		$response = self::response_or_error( wp_remote_post( $url, $args ) );
44
+		$response = self::response_or_error(wp_remote_post($url, $args));
45 45
 
46
-		if ( is_wp_error( $response ) ) {
46
+		if (is_wp_error($response)) {
47 47
 			return $response;
48 48
 		}
49 49
 
50
-		if ( ! isset( $response->access_token ) ) {
51
-			return new \WP_Error( 'invalid_request', 'Could not create token.', array( 'status' => 400 ) );
50
+		if (!isset($response->access_token)) {
51
+			return new \WP_Error('invalid_request', 'Could not create token.', array('status' => 400));
52 52
 		}
53 53
 
54
-		set_transient( 'getpaid_paypal_' . $mode . '_token', $response->access_token, $response->expires_in - 600 );
54
+		set_transient('getpaid_paypal_' . $mode . '_token', $response->access_token, $response->expires_in - 600);
55 55
 		return $response->access_token;
56 56
 	}
57 57
 
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 	 * @param string $endpoint
62 62
 	 * @return string
63 63
 	 */
64
-	public static function get_api_url( $endpoint = '', $mode = 'live'  ) {
65
-		$endpoint = ltrim( $endpoint, '/' );
64
+	public static function get_api_url($endpoint = '', $mode = 'live') {
65
+		$endpoint = ltrim($endpoint, '/');
66 66
 		return 'live' === $mode ? 'https://api-m.paypal.com/' . $endpoint : 'https://api-m.sandbox.paypal.com/' . $endpoint;
67 67
 	}
68 68
 
@@ -75,15 +75,15 @@  discard block
 block discarded – undo
75 75
 	 *
76 76
 	 * @return true|\WP_Error
77 77
 	 */
78
-	public static function post( $path, $data, $mode = 'live', $method = 'POST' ) {
78
+	public static function post($path, $data, $mode = 'live', $method = 'POST') {
79 79
 
80
-		$access_token = self::get_token( $mode );
80
+		$access_token = self::get_token($mode);
81 81
 
82
-		if ( is_wp_error( $access_token ) ) {
82
+		if (is_wp_error($access_token)) {
83 83
 			return $access_token;
84 84
 		}
85 85
 
86
-		$url  = self::get_api_url( $path, $mode );
86
+		$url  = self::get_api_url($path, $mode);
87 87
 		$args = array(
88 88
 			'method'  => $method,
89 89
 			'headers' => array(
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
 			),
93 93
 		);
94 94
 
95
-		if( ! empty( $data )) {
96
-			$args['body'] = wp_json_encode( $data );
95
+		if (!empty($data)) {
96
+			$args['body'] = wp_json_encode($data);
97 97
 		}
98 98
 
99
-		return self::response_or_error( wp_remote_post( $url, $args ) );
99
+		return self::response_or_error(wp_remote_post($url, $args));
100 100
 	}
101 101
 
102 102
 	/**
@@ -106,15 +106,15 @@  discard block
 block discarded – undo
106 106
 	 * @param string $method
107 107
 	 * @return object|\WP_Error
108 108
 	 */
109
-	public static function get( $path, $mode = 'live', $method = 'GET' ) {
109
+	public static function get($path, $mode = 'live', $method = 'GET') {
110 110
 
111
-		$access_token = self::get_token( $mode );
111
+		$access_token = self::get_token($mode);
112 112
 
113
-		if ( is_wp_error( $access_token ) ) {
113
+		if (is_wp_error($access_token)) {
114 114
 			return $access_token;
115 115
 		}
116 116
 
117
-		$url  = self::get_api_url( $path, $mode );
117
+		$url  = self::get_api_url($path, $mode);
118 118
 		$args = array(
119 119
 			'method'  => $method,
120 120
 			'headers' => array(
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 			),
123 123
 		);
124 124
 
125
-		return self::response_or_error( wp_remote_get( $url, $args ) );
125
+		return self::response_or_error(wp_remote_get($url, $args));
126 126
 	}
127 127
 
128 128
 	/**
@@ -133,33 +133,33 @@  discard block
 block discarded – undo
133 133
 	 * @param \WP_Error|array $response
134 134
 	 * @return \WP_Error|object
135 135
 	 */
136
-	public static function response_or_error( $response ) {
136
+	public static function response_or_error($response) {
137 137
 
138
-		if ( is_wp_error( $response ) ) {
139
-			return new \WP_Error( 'paypal_error', __( 'There was a problem connecting to the PayPal API endpoint.', 'invoicing' ) );
138
+		if (is_wp_error($response)) {
139
+			return new \WP_Error('paypal_error', __('There was a problem connecting to the PayPal API endpoint.', 'invoicing'));
140 140
 		}
141 141
 
142
-		if ( empty( $response['body'] ) ) {
142
+		if (empty($response['body'])) {
143 143
 			return true;
144 144
 		}
145 145
 
146
-		$response_body = json_decode( wp_remote_retrieve_body( $response ) );
146
+		$response_body = json_decode(wp_remote_retrieve_body($response));
147 147
 
148
-		if ( wp_remote_retrieve_response_code( $response ) > 299 ) {
148
+		if (wp_remote_retrieve_response_code($response) > 299) {
149 149
 
150 150
 			// Normal errors.
151
-			if ( $response_body && isset( $response_body->message ) ) {
151
+			if ($response_body && isset($response_body->message)) {
152 152
 				$error_message = $response_body->message;
153 153
 
154 154
 			// Identity errors.
155
-			} elseif ( $response_body && isset( $response_body->error_description ) ) {
155
+			} elseif ($response_body && isset($response_body->error_description)) {
156 156
 				$error_message = $response_body->error_description;
157
-				return new \WP_Error( 'paypal_error', wp_kses_post( $response_body->error_description ) );
157
+				return new \WP_Error('paypal_error', wp_kses_post($response_body->error_description));
158 158
 			} else {
159
-				$error_message = __( 'There was an error connecting to the PayPal API endpoint.', 'invoicing' );
159
+				$error_message = __('There was an error connecting to the PayPal API endpoint.', 'invoicing');
160 160
 			}
161 161
 
162
-			return new \WP_Error( 'paypal_error', $error_message );
162
+			return new \WP_Error('paypal_error', $error_message);
163 163
 		}
164 164
 
165 165
 		return $response_body;
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 	 * @link https://developer.paypal.com/docs/api/orders/v2/#orders_get
175 175
 	 * @return \WP_Error|object
176 176
 	 */
177
-	public static function get_order( $order_id, $mode = 'live' ) {
178
-		return self::get( '/v2/checkout/orders/' . $order_id, $mode );
177
+	public static function get_order($order_id, $mode = 'live') {
178
+		return self::get('/v2/checkout/orders/' . $order_id, $mode);
179 179
 	}
180 180
 
181 181
 	/**
@@ -187,8 +187,8 @@  discard block
 block discarded – undo
187 187
 	 * @link https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_get
188 188
 	 * @return \WP_Error|object
189 189
 	 */
190
-	public static function get_subscription( $subscription_id, $mode = 'live' ) {
191
-		return self::get( '/v1/billing/subscriptions/' . $subscription_id, $mode );
190
+	public static function get_subscription($subscription_id, $mode = 'live') {
191
+		return self::get('/v1/billing/subscriptions/' . $subscription_id, $mode);
192 192
 	}
193 193
 
194 194
 	/**
@@ -200,10 +200,10 @@  discard block
 block discarded – undo
200 200
 	 * @link https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_transactions
201 201
 	 * @return \WP_Error|object
202 202
 	 */
203
-	public static function get_subscription_transaction( $subscription_id, $mode = 'live' ) {
204
-		$start_time = gmdate( 'Y-m-d\TH:i:s\Z', strtotime( '-1 day' ) );
205
-		$end_time   = gmdate( 'Y-m-d\TH:i:s\Z' );
206
-		return self::get( "/v1/billing/subscriptions/$subscription_id/transactions?start_time=$start_time&end_time=$end_time", $mode );
203
+	public static function get_subscription_transaction($subscription_id, $mode = 'live') {
204
+		$start_time = gmdate('Y-m-d\TH:i:s\Z', strtotime('-1 day'));
205
+		$end_time   = gmdate('Y-m-d\TH:i:s\Z');
206
+		return self::get("/v1/billing/subscriptions/$subscription_id/transactions?start_time=$start_time&end_time=$end_time", $mode);
207 207
 	}
208 208
 
209 209
 	/**
@@ -216,8 +216,8 @@  discard block
 block discarded – undo
216 216
 	 * @link https://developer.paypal.com/docs/api/payments/v2/#captures_refund
217 217
 	 * @return \WP_Error|object
218 218
 	 */
219
-	public static function refund_capture( $capture_id, $args = array(), $mode = 'live' ) {
220
-		return self::post( '/v2/payments/captures/' . $capture_id . '/refund', $args, $mode );
219
+	public static function refund_capture($capture_id, $args = array(), $mode = 'live') {
220
+		return self::post('/v2/payments/captures/' . $capture_id . '/refund', $args, $mode);
221 221
 	}
222 222
 
223 223
 	/**
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	 * @link https://developer.paypal.com/docs/api/subscriptions/v1/#subscriptions_cancel
231 231
 	 * @return \WP_Error|object
232 232
 	 */
233
-	public static function cancel_subscription( $subscription_id, $args = array(), $mode = 'live' ) {
234
-		return self::post( '/v1/billing/subscriptions/' . $subscription_id . '/cancel', $args, $mode );
233
+	public static function cancel_subscription($subscription_id, $args = array(), $mode = 'live') {
234
+		return self::post('/v1/billing/subscriptions/' . $subscription_id . '/cancel', $args, $mode);
235 235
 	}
236 236
 }
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-paypal-gateway.php 2 patches
Indentation   +508 added lines, -508 removed lines patch added patch discarded remove patch
@@ -13,103 +13,103 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Paypal_Gateway extends GetPaid_Payment_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'paypal';
21 21
 
22 22
     /**
23
-	 * An array of features that this gateway supports.
24
-	 *
25
-	 * @var array
26
-	 */
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27 27
     protected $supports = array( 'subscription', 'sandbox', 'single_subscription_group', 'refunds' );
28 28
 
29 29
     /**
30
-	 * Payment method order.
31
-	 *
32
-	 * @var int
33
-	 */
30
+     * Payment method order.
31
+     *
32
+     * @var int
33
+     */
34 34
     public $order = 1;
35 35
 
36 36
     /**
37
-	 * Stores line items to send to PayPal.
38
-	 *
39
-	 * @var array
40
-	 */
37
+     * Stores line items to send to PayPal.
38
+     *
39
+     * @var array
40
+     */
41 41
     protected $line_items = array();
42 42
 
43 43
     /**
44
-	 * Endpoint for requests from PayPal.
45
-	 *
46
-	 * @var string
47
-	 */
48
-	protected $notify_url;
44
+     * Endpoint for requests from PayPal.
45
+     *
46
+     * @var string
47
+     */
48
+    protected $notify_url;
49 49
 
50
-	/**
51
-	 * Endpoint for requests to PayPal.
52
-	 *
53
-	 * @var string
54
-	 */
50
+    /**
51
+     * Endpoint for requests to PayPal.
52
+     *
53
+     * @var string
54
+     */
55 55
     protected $endpoint;
56 56
 
57 57
     /**
58
-	 * Currencies this gateway is allowed for.
59
-	 *
60
-	 * @var array
61
-	 */
62
-	public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' );
58
+     * Currencies this gateway is allowed for.
59
+     *
60
+     * @var array
61
+     */
62
+    public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' );
63 63
 
64 64
     /**
65
-	 * URL to view a transaction.
66
-	 *
67
-	 * @var string
68
-	 */
65
+     * URL to view a transaction.
66
+     *
67
+     * @var string
68
+     */
69 69
     public $view_transaction_url = 'https://www.{sandbox}paypal.com/activity/payment/%s';
70 70
 
71 71
     /**
72
-	 * URL to view a subscription.
73
-	 *
74
-	 * @var string
75
-	 */
76
-	public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s';
72
+     * URL to view a subscription.
73
+     *
74
+     * @var string
75
+     */
76
+    public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s';
77 77
 
78 78
     /**
79
-	 * Class constructor.
80
-	 */
81
-	public function __construct() {
82
-		parent::__construct();
79
+     * Class constructor.
80
+     */
81
+    public function __construct() {
82
+        parent::__construct();
83 83
 
84 84
         $this->title                = __( 'PayPal Standard', 'invoicing' );
85 85
         $this->method_title         = __( 'PayPal Standard', 'invoicing' );
86 86
         $this->checkout_button_text = __( 'Proceed to PayPal', 'invoicing' );
87 87
         $this->notify_url           = wpinv_get_ipn_url( $this->id );
88 88
 
89
-		add_filter( 'wpinv_subscription_cancel_url', array( $this, 'filter_cancel_subscription_url' ), 10, 2 );
90
-		add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 );
91
-		add_filter( 'getpaid_get_paypal_connect_url', array( $this, 'maybe_get_connect_url' ), 10, 2 );
92
-		add_action( 'getpaid_authenticated_admin_action_connect_paypal', array( $this, 'connect_paypal' ) );
93
-		add_action( 'wpinv_paypal_connect', array( $this, 'display_connect_buttons' ) );
94
-
95
-		if ( $this->enabled ) {
96
-			add_filter( 'getpaid_paypal_sandbox_notice', array( $this, 'sandbox_notice' ) );
97
-			add_action( 'getpaid_paypal_subscription_cancelled', array( $this, 'subscription_cancelled' ) );
98
-			add_action( 'getpaid_delete_subscription', array( $this, 'subscription_cancelled' ) );
99
-			add_action( 'getpaid_refund_invoice_remotely', array( $this, 'refund_invoice' ) );
100
-		}
89
+        add_filter( 'wpinv_subscription_cancel_url', array( $this, 'filter_cancel_subscription_url' ), 10, 2 );
90
+        add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 );
91
+        add_filter( 'getpaid_get_paypal_connect_url', array( $this, 'maybe_get_connect_url' ), 10, 2 );
92
+        add_action( 'getpaid_authenticated_admin_action_connect_paypal', array( $this, 'connect_paypal' ) );
93
+        add_action( 'wpinv_paypal_connect', array( $this, 'display_connect_buttons' ) );
94
+
95
+        if ( $this->enabled ) {
96
+            add_filter( 'getpaid_paypal_sandbox_notice', array( $this, 'sandbox_notice' ) );
97
+            add_action( 'getpaid_paypal_subscription_cancelled', array( $this, 'subscription_cancelled' ) );
98
+            add_action( 'getpaid_delete_subscription', array( $this, 'subscription_cancelled' ) );
99
+            add_action( 'getpaid_refund_invoice_remotely', array( $this, 'refund_invoice' ) );
100
+        }
101 101
     }
102 102
 
103 103
     /**
104
-	 * Process Payment.
105
-	 *
106
-	 *
107
-	 * @param WPInv_Invoice $invoice Invoice.
108
-	 * @param array $submission_data Posted checkout fields.
109
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
110
-	 * @return array
111
-	 */
112
-	public function process_payment( $invoice, $submission_data, $submission ) {
104
+     * Process Payment.
105
+     *
106
+     *
107
+     * @param WPInv_Invoice $invoice Invoice.
108
+     * @param array $submission_data Posted checkout fields.
109
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
110
+     * @return array
111
+     */
112
+    public function process_payment( $invoice, $submission_data, $submission ) {
113 113
 
114 114
         // Get redirect url.
115 115
         $paypal_redirect = $this->get_request_url( $invoice );
@@ -132,15 +132,15 @@  discard block
 block discarded – undo
132 132
     }
133 133
 
134 134
     /**
135
-	 * Get the PayPal request URL for an invoice.
136
-	 *
137
-	 * @param  WPInv_Invoice $invoice Invoice object.
138
-	 * @return string
139
-	 */
140
-	public function get_request_url( $invoice ) {
135
+     * Get the PayPal request URL for an invoice.
136
+     *
137
+     * @param  WPInv_Invoice $invoice Invoice object.
138
+     * @return string
139
+     */
140
+    public function get_request_url( $invoice ) {
141 141
 
142 142
         // Endpoint for this request
143
-		$this->endpoint    = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
143
+        $this->endpoint    = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
144 144
 
145 145
         // Retrieve paypal args.
146 146
         $paypal_args       = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' );
@@ -153,45 +153,45 @@  discard block
 block discarded – undo
153 153
 
154 154
         return add_query_arg( $paypal_args, $this->endpoint );
155 155
 
156
-	}
156
+    }
157 157
 
158 158
     /**
159
-	 * Get PayPal Args for passing to PP.
160
-	 *
161
-	 * @param  WPInv_Invoice $invoice Invoice object.
162
-	 * @return array
163
-	 */
164
-	protected function get_paypal_args( $invoice ) {
159
+     * Get PayPal Args for passing to PP.
160
+     *
161
+     * @param  WPInv_Invoice $invoice Invoice object.
162
+     * @return array
163
+     */
164
+    protected function get_paypal_args( $invoice ) {
165 165
 
166 166
         // Whether or not to send the line items as one item.
167
-		$force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', true, $invoice );
168
-
169
-		if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) {
170
-			$force_one_line_item = true;
171
-		}
172
-
173
-		$paypal_args = apply_filters(
174
-			'getpaid_paypal_args',
175
-			array_merge(
176
-				$this->get_transaction_args( $invoice ),
177
-				$this->get_line_item_args( $invoice, $force_one_line_item )
178
-			),
179
-			$invoice
180
-		);
181
-
182
-		return $this->fix_request_length( $invoice, $paypal_args );
167
+        $force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', true, $invoice );
168
+
169
+        if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) {
170
+            $force_one_line_item = true;
171
+        }
172
+
173
+        $paypal_args = apply_filters(
174
+            'getpaid_paypal_args',
175
+            array_merge(
176
+                $this->get_transaction_args( $invoice ),
177
+                $this->get_line_item_args( $invoice, $force_one_line_item )
178
+            ),
179
+            $invoice
180
+        );
181
+
182
+        return $this->fix_request_length( $invoice, $paypal_args );
183 183
     }
184 184
 
185 185
     /**
186
-	 * Get transaction args for paypal request.
187
-	 *
188
-	 * @param WPInv_Invoice $invoice Invoice object.
189
-	 * @return array
190
-	 */
191
-	protected function get_transaction_args( $invoice ) {
186
+     * Get transaction args for paypal request.
187
+     *
188
+     * @param WPInv_Invoice $invoice Invoice object.
189
+     * @return array
190
+     */
191
+    protected function get_transaction_args( $invoice ) {
192 192
 
193
-		$email = $this->is_sandbox( $invoice ) ? wpinv_get_option( 'paypal_sandbox_email', wpinv_get_option( 'paypal_email', '' ) ) : wpinv_get_option( 'paypal_email', '' );
194
-		return array(
193
+        $email = $this->is_sandbox( $invoice ) ? wpinv_get_option( 'paypal_sandbox_email', wpinv_get_option( 'paypal_email', '' ) ) : wpinv_get_option( 'paypal_email', '' );
194
+        return array(
195 195
             'cmd'           => '_cart',
196 196
             'business'      => $email,
197 197
             'no_shipping'   => '1',
@@ -216,16 +216,16 @@  discard block
 block discarded – undo
216 216
     }
217 217
 
218 218
     /**
219
-	 * Get line item args for paypal request.
220
-	 *
221
-	 * @param  WPInv_Invoice $invoice Invoice object.
222
-	 * @param  bool     $force_one_line_item Create only one item for this invoice.
223
-	 * @return array
224
-	 */
225
-	protected function get_line_item_args( $invoice, $force_one_line_item = false ) {
219
+     * Get line item args for paypal request.
220
+     *
221
+     * @param  WPInv_Invoice $invoice Invoice object.
222
+     * @param  bool     $force_one_line_item Create only one item for this invoice.
223
+     * @return array
224
+     */
225
+    protected function get_line_item_args( $invoice, $force_one_line_item = false ) {
226 226
 
227 227
         // Maybe send invoice as a single item.
228
-		if ( $force_one_line_item ) {
228
+        if ( $force_one_line_item ) {
229 229
             return $this->get_line_item_args_single_item( $invoice );
230 230
         }
231 231
 
@@ -245,134 +245,134 @@  discard block
 block discarded – undo
245 245
             $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 );
246 246
         }
247 247
 
248
-		return array_merge( $line_item_args, $this->get_line_items() );
248
+        return array_merge( $line_item_args, $this->get_line_items() );
249 249
 
250 250
     }
251 251
 
252 252
     /**
253
-	 * Get line item args for paypal request as a single line item.
254
-	 *
255
-	 * @param  WPInv_Invoice $invoice Invoice object.
256
-	 * @return array
257
-	 */
258
-	protected function get_line_item_args_single_item( $invoice ) {
259
-		$this->delete_line_items();
253
+     * Get line item args for paypal request as a single line item.
254
+     *
255
+     * @param  WPInv_Invoice $invoice Invoice object.
256
+     * @return array
257
+     */
258
+    protected function get_line_item_args_single_item( $invoice ) {
259
+        $this->delete_line_items();
260 260
 
261 261
         $item_name = wp_sprintf( __( 'Invoice %s', 'invoicing' ), $invoice->get_number() );
262
-		$this->add_line_item( $item_name, 1, wpinv_round_amount( (float) $invoice->get_total(), 2, true ), $invoice->get_id() );
262
+        $this->add_line_item( $item_name, 1, wpinv_round_amount( (float) $invoice->get_total(), 2, true ), $invoice->get_id() );
263 263
 
264
-		return $this->get_line_items();
264
+        return $this->get_line_items();
265 265
     }
266 266
 
267 267
     /**
268
-	 * Return all line items.
269
-	 */
270
-	protected function get_line_items() {
271
-		return $this->line_items;
272
-	}
268
+     * Return all line items.
269
+     */
270
+    protected function get_line_items() {
271
+        return $this->line_items;
272
+    }
273 273
 
274 274
     /**
275
-	 * Remove all line items.
276
-	 */
277
-	protected function delete_line_items() {
278
-		$this->line_items = array();
275
+     * Remove all line items.
276
+     */
277
+    protected function delete_line_items() {
278
+        $this->line_items = array();
279 279
     }
280 280
 
281 281
     /**
282
-	 * Prepare line items to send to paypal.
283
-	 *
284
-	 * @param  WPInv_Invoice $invoice Invoice object.
285
-	 */
286
-	protected function prepare_line_items( $invoice ) {
287
-		$this->delete_line_items();
288
-
289
-		// Items.
290
-		foreach ( $invoice->get_items() as $item ) {
291
-			$amount   = $item->get_price();
292
-			$quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity();
293
-			$this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() );
282
+     * Prepare line items to send to paypal.
283
+     *
284
+     * @param  WPInv_Invoice $invoice Invoice object.
285
+     */
286
+    protected function prepare_line_items( $invoice ) {
287
+        $this->delete_line_items();
288
+
289
+        // Items.
290
+        foreach ( $invoice->get_items() as $item ) {
291
+            $amount   = $item->get_price();
292
+            $quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity();
293
+            $this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() );
294 294
         }
295 295
 
296 296
         // Fees.
297
-		foreach ( $invoice->get_fees() as $fee => $data ) {
297
+        foreach ( $invoice->get_fees() as $fee => $data ) {
298 298
             $this->add_line_item( $fee, 1, wpinv_sanitize_amount( $data['initial_fee'] ) );
299 299
         }
300 300
 
301 301
     }
302 302
 
303 303
     /**
304
-	 * Add PayPal Line Item.
305
-	 *
306
-	 * @param  string $item_name Item name.
307
-	 * @param  float    $quantity Item quantity.
308
-	 * @param  float  $amount Amount.
309
-	 * @param  string $item_number Item number.
310
-	 */
311
-	protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) {
312
-		$index = ( count( $this->line_items ) / 4 ) + 1;
313
-
314
-		/**
315
-		 * Prevent error "Things don't appear to be working at the moment. (https://www.sandbox.paypal.com/webapps/hermes/error)"
316
-		 */
317
-		$item_name = str_replace( "#", "", $item_name );
318
-
319
-		$item = apply_filters(
320
-			'getpaid_paypal_line_item',
321
-			array(
322
-				'item_name'   => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
323
-				'quantity'    => (float) $quantity,
324
-				'amount'      => wpinv_sanitize_amount( (float) $amount, 2 ),
325
-				'item_number' => $item_number,
326
-			),
327
-			$item_name,
328
-			$quantity,
329
-			$amount,
330
-			$item_number
331
-		);
332
-
333
-		$this->line_items[ 'item_name_' . $index ]   = getpaid_limit_length( $item['item_name'], 127 );
304
+     * Add PayPal Line Item.
305
+     *
306
+     * @param  string $item_name Item name.
307
+     * @param  float    $quantity Item quantity.
308
+     * @param  float  $amount Amount.
309
+     * @param  string $item_number Item number.
310
+     */
311
+    protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) {
312
+        $index = ( count( $this->line_items ) / 4 ) + 1;
313
+
314
+        /**
315
+         * Prevent error "Things don't appear to be working at the moment. (https://www.sandbox.paypal.com/webapps/hermes/error)"
316
+         */
317
+        $item_name = str_replace( "#", "", $item_name );
318
+
319
+        $item = apply_filters(
320
+            'getpaid_paypal_line_item',
321
+            array(
322
+                'item_name'   => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
323
+                'quantity'    => (float) $quantity,
324
+                'amount'      => wpinv_sanitize_amount( (float) $amount, 2 ),
325
+                'item_number' => $item_number,
326
+            ),
327
+            $item_name,
328
+            $quantity,
329
+            $amount,
330
+            $item_number
331
+        );
332
+
333
+        $this->line_items[ 'item_name_' . $index ]   = getpaid_limit_length( $item['item_name'], 127 );
334 334
         $this->line_items[ 'quantity_' . $index ]    = $item['quantity'];
335 335
 
336 336
         // The price or amount of the product, service, or contribution, not including shipping, handling, or tax.
337
-		$this->line_items[ 'amount_' . $index ]      = $item['amount'] * $item['quantity'];
338
-		$this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 );
337
+        $this->line_items[ 'amount_' . $index ]      = $item['amount'] * $item['quantity'];
338
+        $this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 );
339 339
     }
340 340
 
341 341
     /**
342
-	 * If the default request with line items is too long, generate a new one with only one line item.
343
-	 *
344
-	 * https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer.
345
-	 *
346
-	 * @param WPInv_Invoice $invoice Invoice to be sent to Paypal.
347
-	 * @param array    $paypal_args Arguments sent to Paypal in the request.
348
-	 * @return array
349
-	 */
350
-	protected function fix_request_length( $invoice, $paypal_args ) {
351
-		$max_paypal_length = 2083;
352
-		$query_candidate   = http_build_query( $paypal_args, '', '&' );
353
-
354
-		if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) {
355
-			return $paypal_args;
356
-		}
357
-
358
-		return apply_filters(
359
-			'getpaid_paypal_args',
360
-			array_merge(
361
-				$this->get_transaction_args( $invoice ),
362
-				$this->get_line_item_args( $invoice, true )
363
-			),
364
-			$invoice
365
-		);
342
+     * If the default request with line items is too long, generate a new one with only one line item.
343
+     *
344
+     * https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer.
345
+     *
346
+     * @param WPInv_Invoice $invoice Invoice to be sent to Paypal.
347
+     * @param array    $paypal_args Arguments sent to Paypal in the request.
348
+     * @return array
349
+     */
350
+    protected function fix_request_length( $invoice, $paypal_args ) {
351
+        $max_paypal_length = 2083;
352
+        $query_candidate   = http_build_query( $paypal_args, '', '&' );
353
+
354
+        if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) {
355
+            return $paypal_args;
356
+        }
357
+
358
+        return apply_filters(
359
+            'getpaid_paypal_args',
360
+            array_merge(
361
+                $this->get_transaction_args( $invoice ),
362
+                $this->get_line_item_args( $invoice, true )
363
+            ),
364
+            $invoice
365
+        );
366 366
 
367 367
     }
368 368
 
369 369
     /**
370
-	 * Processes recurring invoices.
371
-	 *
372
-	 * @param  array $paypal_args PayPal args.
373
-	 * @param  WPInv_Invoice    $invoice Invoice object.
374
-	 */
375
-	public function process_subscription( $paypal_args, $invoice ) {
370
+     * Processes recurring invoices.
371
+     *
372
+     * @param  array $paypal_args PayPal args.
373
+     * @param  WPInv_Invoice    $invoice Invoice object.
374
+     */
375
+    public function process_subscription( $paypal_args, $invoice ) {
376 376
 
377 377
         // Make sure this is a subscription.
378 378
         if ( ! $invoice->is_recurring() || ! $subscription = getpaid_get_invoice_subscription( $invoice ) ) {
@@ -393,21 +393,21 @@  discard block
 block discarded – undo
393 393
         $recurring_amount       = (float) wpinv_sanitize_amount( $invoice->get_recurring_total(), 2 );
394 394
         $subscription_item      = $invoice->get_recurring( true );
395 395
 
396
-		// Convert 365 days to 1 year.
397
-		if ( 'D' == $period && 365 == $interval ) {
398
-			$period = 'Y';
399
-			$interval = 1;
400
-		}
396
+        // Convert 365 days to 1 year.
397
+        if ( 'D' == $period && 365 == $interval ) {
398
+            $period = 'Y';
399
+            $interval = 1;
400
+        }
401 401
 
402 402
         if ( $subscription_item->has_free_trial() ) {
403 403
 
404 404
             $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount;
405 405
 
406
-			// Trial period length.
407
-			$paypal_args['p1'] = $subscription_item->get_trial_interval();
406
+            // Trial period length.
407
+            $paypal_args['p1'] = $subscription_item->get_trial_interval();
408 408
 
409
-			// Trial period.
410
-			$paypal_args['t1'] = $subscription_item->get_trial_period();
409
+            // Trial period.
410
+            $paypal_args['t1'] = $subscription_item->get_trial_period();
411 411
 
412 412
         } elseif ( $initial_amount != $recurring_amount ) {
413 413
 
@@ -430,40 +430,40 @@  discard block
 block discarded – undo
430 430
         }
431 431
 
432 432
         // We have a recurring payment
433
-		if ( ! isset( $param_number ) || 1 == $param_number ) {
433
+        if ( ! isset( $param_number ) || 1 == $param_number ) {
434 434
 
435
-			// Subscription price
436
-			$paypal_args['a3'] = $recurring_amount;
435
+            // Subscription price
436
+            $paypal_args['a3'] = $recurring_amount;
437 437
 
438
-			// Subscription duration
439
-			$paypal_args['p3'] = $interval;
438
+            // Subscription duration
439
+            $paypal_args['p3'] = $interval;
440 440
 
441
-			// Subscription period
442
-			$paypal_args['t3'] = $period;
441
+            // Subscription period
442
+            $paypal_args['t3'] = $period;
443 443
 
444 444
         }
445 445
 
446 446
         // Recurring payments
447
-		if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) {
447
+        if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) {
448 448
 
449
-			// Non-recurring payments
450
-			$paypal_args['src'] = 0;
449
+            // Non-recurring payments
450
+            $paypal_args['src'] = 0;
451 451
 
452
-		} else {
452
+        } else {
453 453
 
454
-			$paypal_args['src'] = 1;
454
+            $paypal_args['src'] = 1;
455 455
 
456
-			if ( $bill_times > 0 ) {
456
+            if ( $bill_times > 0 ) {
457 457
 
458
-				// An initial period is being used to charge a sign-up fee
459
-				if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) {
460
-					$bill_times--;
461
-				}
458
+                // An initial period is being used to charge a sign-up fee
459
+                if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) {
460
+                    $bill_times--;
461
+                }
462 462
 
463 463
                 // Make sure it's not over the max of 52
464 464
                 $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 );
465 465
 
466
-			}
466
+            }
467 467
         }
468 468
 
469 469
         // Force return URL so that order description & instructions display
@@ -475,115 +475,115 @@  discard block
 block discarded – undo
475 475
             if ( isset( $paypal_args[ $arg ] ) ) {
476 476
                 unset( $paypal_args[ $arg ] );
477 477
             }
478
-		}
478
+        }
479 479
 
480 480
         return apply_filters(
481
-			'getpaid_paypal_subscription_args',
482
-			$paypal_args,
483
-			$invoice
481
+            'getpaid_paypal_subscription_args',
482
+            $paypal_args,
483
+            $invoice
484
+        );
485
+
486
+    }
487
+
488
+    /**
489
+     * Refunds an invoice remotely.
490
+     * 
491
+     * @since 2.8.24
492
+     * @param WPInv_Invoice $invoice Invoice object.
493
+     */
494
+    public function refund_invoice( $invoice ) {
495
+
496
+        if ( $invoice->get_gateway() !== $this->id ) {
497
+            return;
498
+        }
499
+
500
+        $mode	= $this->is_sandbox( $invoice ) ? 'sandbox' : 'live';
501
+        $result = GetPaid_PayPal_API::refund_capture( $invoice->get_transaction_id(), array(), $mode );
502
+
503
+        if ( is_wp_error( $result ) ) {
504
+            $invoice->add_system_note(
505
+                sprintf(
506
+                    // translators: %s is the error message.
507
+                    __( 'An error occured while trying to refund invoice #%1$s in PayPal: %2$s', 'invoicing' ),
508
+                    $invoice->get_id(),
509
+                    $result->get_error_message()
510
+                )
511
+            );
512
+        } else {
513
+            $invoice->add_system_note(
514
+                sprintf(
515
+                    // translators: %s is the refund ID.
516
+                    __( 'Successfully refunded invoice #%1$s in PayPal. Refund ID: %2$s', 'invoicing' ),
517
+                    $invoice->get_id(),
518
+                    $result->id
519
+                )
520
+            );
521
+        }
522
+    }
523
+
524
+    /**
525
+     * Cancels a subscription remotely.
526
+     * 
527
+     * @since 2.8.24
528
+     * @param WPInv_Subscription $subscription Subscription object.
529
+     */
530
+    public function subscription_cancelled( $subscription ) {
531
+
532
+        if ( $subscription->get_gateway() != $this->id ) {
533
+            return;
534
+        }
535
+
536
+        $invoice = $subscription->get_parent_invoice();
537
+
538
+        // Abort if the parent invoice does not exist.
539
+        if ( ! $invoice->exists() ) {
540
+            return;
541
+        }
542
+
543
+        $mode	= $this->is_sandbox( $invoice ) ? 'sandbox' : 'live';
544
+        $result = GetPaid_PayPal_API::cancel_subscription( 
545
+            $invoice->get_remote_subscription_id(), 
546
+            array(
547
+                'reason' => __(' Customer requested cancellation', 'invoicing' ),
548
+            ), 
549
+            $mode 
484 550
         );
485 551
 
552
+        if ( is_wp_error( $result ) ) {
553
+
554
+            $error = sprintf(
555
+                // translators: %s is the subscription ID.
556
+                __( 'An error occured while trying to cancel subscription #%s in PayPal.', 'invoicing' ),
557
+                $subscription->get_id()
558
+            );
559
+
560
+            getpaid_admin()->show_error( $error . ' ' . $result->get_error_message() );
561
+
562
+            if ( ! is_admin() ) {
563
+                wpinv_set_error( $result->get_error_code(), $error );
564
+            }
565
+
566
+            return;
567
+        }
568
+
569
+        if ( is_admin() ) {
570
+            getpaid_admin()->show_success(
571
+                sprintf(
572
+                    // translators: %s is the subscription ID.
573
+                    __( 'Successfully cancelled subscription #%s in PayPal.', 'invoicing' ),
574
+                    $subscription->get_id()
575
+                )
576
+            );
577
+        }
578
+
486 579
     }
487 580
 
488
-	/**
489
-	 * Refunds an invoice remotely.
490
-	 * 
491
-	 * @since 2.8.24
492
-	 * @param WPInv_Invoice $invoice Invoice object.
493
-	 */
494
-	public function refund_invoice( $invoice ) {
495
-
496
-		if ( $invoice->get_gateway() !== $this->id ) {
497
-			return;
498
-		}
499
-
500
-		$mode	= $this->is_sandbox( $invoice ) ? 'sandbox' : 'live';
501
-		$result = GetPaid_PayPal_API::refund_capture( $invoice->get_transaction_id(), array(), $mode );
502
-
503
-		if ( is_wp_error( $result ) ) {
504
-			$invoice->add_system_note(
505
-				sprintf(
506
-					// translators: %s is the error message.
507
-					__( 'An error occured while trying to refund invoice #%1$s in PayPal: %2$s', 'invoicing' ),
508
-					$invoice->get_id(),
509
-					$result->get_error_message()
510
-				)
511
-			);
512
-		} else {
513
-			$invoice->add_system_note(
514
-				sprintf(
515
-					// translators: %s is the refund ID.
516
-					__( 'Successfully refunded invoice #%1$s in PayPal. Refund ID: %2$s', 'invoicing' ),
517
-					$invoice->get_id(),
518
-					$result->id
519
-				)
520
-			);
521
-		}
522
-	}
523
-
524
-	/**
525
-	 * Cancels a subscription remotely.
526
-	 * 
527
-	 * @since 2.8.24
528
-	 * @param WPInv_Subscription $subscription Subscription object.
529
-	 */
530
-	public function subscription_cancelled( $subscription ) {
531
-
532
-		if ( $subscription->get_gateway() != $this->id ) {
533
-			return;
534
-		}
535
-
536
-		$invoice = $subscription->get_parent_invoice();
537
-
538
-		// Abort if the parent invoice does not exist.
539
-		if ( ! $invoice->exists() ) {
540
-			return;
541
-		}
542
-
543
-		$mode	= $this->is_sandbox( $invoice ) ? 'sandbox' : 'live';
544
-		$result = GetPaid_PayPal_API::cancel_subscription( 
545
-			$invoice->get_remote_subscription_id(), 
546
-			array(
547
-				'reason' => __(' Customer requested cancellation', 'invoicing' ),
548
-			), 
549
-			$mode 
550
-		);
551
-
552
-		if ( is_wp_error( $result ) ) {
553
-
554
-			$error = sprintf(
555
-				// translators: %s is the subscription ID.
556
-				__( 'An error occured while trying to cancel subscription #%s in PayPal.', 'invoicing' ),
557
-				$subscription->get_id()
558
-			);
559
-
560
-			getpaid_admin()->show_error( $error . ' ' . $result->get_error_message() );
561
-
562
-			if ( ! is_admin() ) {
563
-				wpinv_set_error( $result->get_error_code(), $error );
564
-			}
565
-
566
-			return;
567
-		}
568
-
569
-		if ( is_admin() ) {
570
-			getpaid_admin()->show_success(
571
-				sprintf(
572
-					// translators: %s is the subscription ID.
573
-					__( 'Successfully cancelled subscription #%s in PayPal.', 'invoicing' ),
574
-					$subscription->get_id()
575
-				)
576
-			);
577
-		}
578
-
579
-	}
580
-
581
-    /**
582
-	 * Processes ipns and marks payments as complete.
583
-	 *
584
-	 * @return void
585
-	 */
586
-	public function verify_ipn() {
581
+    /**
582
+     * Processes ipns and marks payments as complete.
583
+     *
584
+     * @return void
585
+     */
586
+    public function verify_ipn() {
587 587
         new GetPaid_Paypal_Gateway_IPN_Handler( $this );
588 588
     }
589 589
 
@@ -593,19 +593,19 @@  discard block
 block discarded – undo
593 593
     public function sandbox_notice() {
594 594
 
595 595
         return sprintf(
596
-			__( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %1$sPayPal Sandbox Testing Guide%2$s for more details.', 'invoicing' ),
597
-			'<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">',
598
-			'</a>'
599
-		);
596
+            __( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %1$sPayPal Sandbox Testing Guide%2$s for more details.', 'invoicing' ),
597
+            '<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">',
598
+            '</a>'
599
+        );
600 600
 
601 601
     }
602 602
 
603
-	/**
604
-	 * Filters the gateway settings.
605
-	 *
606
-	 * @param array $admin_settings
607
-	 */
608
-	public function admin_settings( $admin_settings ) {
603
+    /**
604
+     * Filters the gateway settings.
605
+     *
606
+     * @param array $admin_settings
607
+     */
608
+    public function admin_settings( $admin_settings ) {
609 609
 
610 610
         $currencies = sprintf(
611 611
             __( 'Supported Currencies: %s', 'invoicing' ),
@@ -615,66 +615,66 @@  discard block
 block discarded – undo
615 615
         $admin_settings['paypal_active']['desc'] .= " ($currencies)";
616 616
         $admin_settings['paypal_desc']['std']     = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' );
617 617
 
618
-		// Access tokens.
619
-		$live_email      = wpinv_get_option( 'paypal_email' );
620
-		$sandbox_email   = wpinv_get_option( 'paypal_sandbox_email' );
618
+        // Access tokens.
619
+        $live_email      = wpinv_get_option( 'paypal_email' );
620
+        $sandbox_email   = wpinv_get_option( 'paypal_sandbox_email' );
621 621
 
622
-		$admin_settings['paypal_connect'] = array(
623
-			'type' => 'hook',
624
-			'id'   => 'paypal_connect',
625
-			'name' => __( 'Connect to PayPal', 'invoicing' ),
626
-		);
622
+        $admin_settings['paypal_connect'] = array(
623
+            'type' => 'hook',
624
+            'id'   => 'paypal_connect',
625
+            'name' => __( 'Connect to PayPal', 'invoicing' ),
626
+        );
627 627
 
628 628
         $admin_settings['paypal_email'] = array(
629 629
             'type'  => 'text',
630
-			'class' => 'live-auth-data',
630
+            'class' => 'live-auth-data',
631 631
             'id'    => 'paypal_email',
632 632
             'name'  => __( 'Live Email Address', 'invoicing' ),
633 633
             'desc'  => __( 'The email address of your PayPal account.', 'invoicing' ),
634 634
         );
635 635
 
636
-		$admin_settings['paypal_sandbox_email'] = array(
636
+        $admin_settings['paypal_sandbox_email'] = array(
637 637
             'type'  => 'text',
638
-			'class' => 'sandbox-auth-data',
638
+            'class' => 'sandbox-auth-data',
639 639
             'id'    => 'paypal_sandbox_email',
640 640
             'name'  => __( 'Sandbox Email Address', 'invoicing' ),
641 641
             'desc'  => __( 'The email address of your sandbox PayPal account.', 'invoicing' ),
642
-			'std'   => wpinv_get_option( 'paypal_email', '' ),
642
+            'std'   => wpinv_get_option( 'paypal_email', '' ),
643
+        );
644
+
645
+        // Client ID and secret.
646
+        $admin_settings['paypal_client_id'] = array(
647
+            'type'  => 'text',
648
+            'class' => 'live-auth-data',
649
+            'id'    => 'paypal_client_id',
650
+            'name'  => __( 'Live Client ID', 'invoicing' ),
651
+            'desc'  => __( 'The client ID of your PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing' ),
652
+        );
653
+
654
+        $admin_settings['paypal_sandbox_client_id'] = array(
655
+            'type'  => 'text',
656
+            'class' => 'sandbox-auth-data',
657
+            'id'    => 'paypal_sandbox_client_id',
658
+            'name'  => __( 'Sandbox Client ID', 'invoicing' ),
659
+            'desc'  => __( 'The client ID of your sandbox PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing' ),
660
+            'std'   => wpinv_get_option( 'paypal_client_id', '' ),
643 661
         );
644 662
 
645
-		// Client ID and secret.
646
-		$admin_settings['paypal_client_id'] = array(
647
-			'type'  => 'text',
648
-			'class' => 'live-auth-data',
649
-			'id'    => 'paypal_client_id',
650
-			'name'  => __( 'Live Client ID', 'invoicing' ),
651
-			'desc'  => __( 'The client ID of your PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing' ),
652
-		);
653
-
654
-		$admin_settings['paypal_sandbox_client_id'] = array(
655
-			'type'  => 'text',
656
-			'class' => 'sandbox-auth-data',
657
-			'id'    => 'paypal_sandbox_client_id',
658
-			'name'  => __( 'Sandbox Client ID', 'invoicing' ),
659
-			'desc'  => __( 'The client ID of your sandbox PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing' ),
660
-			'std'   => wpinv_get_option( 'paypal_client_id', '' ),
661
-		);
662
-
663
-		$admin_settings['paypal_secret'] = array(
664
-			'type'  => 'text',
665
-			'class' => 'live-auth-data',
666
-			'id'    => 'paypal_secret',
667
-			'name'  => __( 'Live Secret', 'invoicing' ),
668
-			'desc'  => __( 'The secret of your PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing' ),
669
-		);
670
-
671
-		$admin_settings['paypal_sandbox_secret'] = array(
672
-			'type'  => 'text',
673
-			'class' => 'sandbox-auth-data',
674
-			'id'    => 'paypal_sandbox_secret',
675
-			'name'  => __( 'Sandbox Secret', 'invoicing' ),
676
-			'desc'  => __( 'The secret of your sandbox PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing' ),
677
-		);
663
+        $admin_settings['paypal_secret'] = array(
664
+            'type'  => 'text',
665
+            'class' => 'live-auth-data',
666
+            'id'    => 'paypal_secret',
667
+            'name'  => __( 'Live Secret', 'invoicing' ),
668
+            'desc'  => __( 'The secret of your PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing' ),
669
+        );
670
+
671
+        $admin_settings['paypal_sandbox_secret'] = array(
672
+            'type'  => 'text',
673
+            'class' => 'sandbox-auth-data',
674
+            'id'    => 'paypal_sandbox_secret',
675
+            'name'  => __( 'Sandbox Secret', 'invoicing' ),
676
+            'desc'  => __( 'The secret of your sandbox PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing' ),
677
+        );
678 678
 
679 679
         $admin_settings['paypal_ipn_url'] = array(
680 680
             'type'     => 'ipn_url',
@@ -685,57 +685,57 @@  discard block
 block discarded – undo
685 685
             'readonly' => true,
686 686
         );
687 687
 
688
-		return $admin_settings;
689
-	}
690
-
691
-	/**
692
-	 * Retrieves the URL to cancel a subscription.
693
-	 *
694
-	 * @param string $url
695
-	 * @param WPInv_Subscription $subscription
696
-	 */
697
-	public function filter_cancel_subscription_url( $url, $subscription ) {
698
-
699
-		if ( $this->id !== $subscription->get_gateway() ) {
700
-			return $url;
701
-		}
702
-
703
-		// Get the PayPal profile ID.
704
-		$profile_id = $subscription->get_profile_id();
705
-
706
-		// Bail if no profile ID.
707
-		if ( empty( $profile_id ) ) {
708
-			return $url;
709
-		}
710
-
711
-		$cancel_url = 'https://www.paypal.com/myaccount/autopay/connect/%s/cancel';
712
-		if ( $this->is_sandbox( $subscription->get_parent_payment() ) ) {
713
-			$cancel_url = 'https://www.sandbox.paypal.com/myaccount/autopay/connect/%s/cancel';
714
-		}
715
-
716
-		return sprintf( $cancel_url, $profile_id );
717
-	}
718
-
719
-	/**
720
-	 * Retrieves the PayPal connect URL when using the setup wizzard.
721
-	 *
722
-	 *
688
+        return $admin_settings;
689
+    }
690
+
691
+    /**
692
+     * Retrieves the URL to cancel a subscription.
693
+     *
694
+     * @param string $url
695
+     * @param WPInv_Subscription $subscription
696
+     */
697
+    public function filter_cancel_subscription_url( $url, $subscription ) {
698
+
699
+        if ( $this->id !== $subscription->get_gateway() ) {
700
+            return $url;
701
+        }
702
+
703
+        // Get the PayPal profile ID.
704
+        $profile_id = $subscription->get_profile_id();
705
+
706
+        // Bail if no profile ID.
707
+        if ( empty( $profile_id ) ) {
708
+            return $url;
709
+        }
710
+
711
+        $cancel_url = 'https://www.paypal.com/myaccount/autopay/connect/%s/cancel';
712
+        if ( $this->is_sandbox( $subscription->get_parent_payment() ) ) {
713
+            $cancel_url = 'https://www.sandbox.paypal.com/myaccount/autopay/connect/%s/cancel';
714
+        }
715
+
716
+        return sprintf( $cancel_url, $profile_id );
717
+    }
718
+
719
+    /**
720
+     * Retrieves the PayPal connect URL when using the setup wizzard.
721
+     *
722
+     *
723 723
      * @param array $data
724 724
      * @return string
725
-	 */
726
-	public static function maybe_get_connect_url( $url = '', $data = array() ) {
727
-		return self::get_connect_url( false, urldecode( $data['redirect'] ) );
728
-	}
729
-
730
-	/**
731
-	 * Retrieves the PayPal connect URL.
732
-	 *
733
-	 *
725
+     */
726
+    public static function maybe_get_connect_url( $url = '', $data = array() ) {
727
+        return self::get_connect_url( false, urldecode( $data['redirect'] ) );
728
+    }
729
+
730
+    /**
731
+     * Retrieves the PayPal connect URL.
732
+     *
733
+     *
734 734
      * @param bool $is_sandbox
735
-	 * @param string $redirect
735
+     * @param string $redirect
736 736
      * @return string
737
-	 */
738
-	public static function get_connect_url( $is_sandbox, $redirect = '' ) {
737
+     */
738
+    public static function get_connect_url( $is_sandbox, $redirect = '' ) {
739 739
 
740 740
         $redirect_url = add_query_arg(
741 741
             array(
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
                 'tab'                  => 'gateways',
746 746
                 'section'              => 'paypal',
747 747
                 'getpaid-nonce'        => wp_create_nonce( 'getpaid-nonce' ),
748
-				'redirect'             => urlencode( $redirect ),
748
+                'redirect'             => urlencode( $redirect ),
749 749
             ),
750 750
             admin_url( 'admin.php' )
751 751
         );
@@ -760,12 +760,12 @@  discard block
 block discarded – undo
760 760
 
761 761
     }
762 762
 
763
-	/**
764
-	 * Generates settings page js.
765
-	 *
763
+    /**
764
+     * Generates settings page js.
765
+     *
766 766
      * @return void
767
-	 */
768
-	public static function display_connect_buttons() {
767
+     */
768
+    public static function display_connect_buttons() {
769 769
 
770 770
         ?>
771 771
 			<div class="wpinv-paypal-connect-live">
@@ -807,70 +807,70 @@  discard block
 block discarded – undo
807 807
         <?php
808 808
     }
809 809
 
810
-	/**
811
-	 * Connects to PayPal.
812
-	 *
813
-	 * @param array $data Connection data.
814
-	 * @return void
815
-	 */
816
-	public function connect_paypal( $data ) {
817
-
818
-		$sandbox      = $this->is_sandbox();
819
-		$data         = wp_unslash( $data );
820
-		$access_token = empty( $data['access_token'] ) ? '' : sanitize_text_field( $data['access_token'] );
821
-
822
-		if ( isset( $data['live_mode'] ) ) {
823
-			$sandbox = empty( $data['live_mode'] );
824
-		}
825
-
826
-		wpinv_update_option( 'paypal_sandbox', (int) $sandbox );
827
-		wpinv_update_option( 'paypal_active', 1 );
828
-
829
-		if ( ! empty( $data['error_description'] ) ) {
830
-			getpaid_admin()->show_error( wp_kses_post( urldecode( $data['error_description'] ) ) );
831
-		} else {
832
-
833
-			// Retrieve the user info.
834
-			$user_info = wp_remote_get(
835
-				! $sandbox ? 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' : 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1',
836
-				array(
837
-
838
-					'headers' => array(
839
-						'Authorization' => 'Bearer ' . $access_token,
840
-						'Content-type'  => 'application/json',
841
-					),
842
-
843
-				)
844
-			);
845
-
846
-			if ( is_wp_error( $user_info ) ) {
847
-				getpaid_admin()->show_error( wp_kses_post( $user_info->get_error_message() ) );
848
-			} else {
849
-
850
-				// Create application.
851
-				$user_info = json_decode( wp_remote_retrieve_body( $user_info ) );
852
-
853
-				if ( $sandbox ) {
854
-					wpinv_update_option( 'paypal_sandbox_email', sanitize_email( $user_info->emails[0]->value ) );
855
-					wpinv_update_option( 'paypal_sandbox_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
856
-					set_transient( 'getpaid_paypal_sandbox_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
857
-					getpaid_admin()->show_success( __( 'Successfully connected your PayPal sandbox account', 'invoicing' ) );
858
-				} else {
859
-					wpinv_update_option( 'paypal_email', sanitize_email( $user_info->emails[0]->value ) );
860
-					wpinv_update_option( 'paypal_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
861
-					set_transient( 'getpaid_paypal_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
862
-					getpaid_admin()->show_success( __( 'Successfully connected your PayPal account', 'invoicing' ) );
863
-				}
864
-			}
865
-		}
866
-
867
-		$redirect = empty( $data['redirect'] ) ? admin_url( 'admin.php?page=wpinv-settings&tab=gateways&section=paypal' ) : urldecode( $data['redirect'] );
868
-
869
-		if ( isset( $data['step'] ) ) {
870
-			$redirect = add_query_arg( 'step', $data['step'], $redirect );
871
-		}
872
-		wp_redirect( $redirect );
873
-		exit;
874
-	}
810
+    /**
811
+     * Connects to PayPal.
812
+     *
813
+     * @param array $data Connection data.
814
+     * @return void
815
+     */
816
+    public function connect_paypal( $data ) {
817
+
818
+        $sandbox      = $this->is_sandbox();
819
+        $data         = wp_unslash( $data );
820
+        $access_token = empty( $data['access_token'] ) ? '' : sanitize_text_field( $data['access_token'] );
821
+
822
+        if ( isset( $data['live_mode'] ) ) {
823
+            $sandbox = empty( $data['live_mode'] );
824
+        }
825
+
826
+        wpinv_update_option( 'paypal_sandbox', (int) $sandbox );
827
+        wpinv_update_option( 'paypal_active', 1 );
828
+
829
+        if ( ! empty( $data['error_description'] ) ) {
830
+            getpaid_admin()->show_error( wp_kses_post( urldecode( $data['error_description'] ) ) );
831
+        } else {
832
+
833
+            // Retrieve the user info.
834
+            $user_info = wp_remote_get(
835
+                ! $sandbox ? 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' : 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1',
836
+                array(
837
+
838
+                    'headers' => array(
839
+                        'Authorization' => 'Bearer ' . $access_token,
840
+                        'Content-type'  => 'application/json',
841
+                    ),
842
+
843
+                )
844
+            );
845
+
846
+            if ( is_wp_error( $user_info ) ) {
847
+                getpaid_admin()->show_error( wp_kses_post( $user_info->get_error_message() ) );
848
+            } else {
849
+
850
+                // Create application.
851
+                $user_info = json_decode( wp_remote_retrieve_body( $user_info ) );
852
+
853
+                if ( $sandbox ) {
854
+                    wpinv_update_option( 'paypal_sandbox_email', sanitize_email( $user_info->emails[0]->value ) );
855
+                    wpinv_update_option( 'paypal_sandbox_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
856
+                    set_transient( 'getpaid_paypal_sandbox_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
857
+                    getpaid_admin()->show_success( __( 'Successfully connected your PayPal sandbox account', 'invoicing' ) );
858
+                } else {
859
+                    wpinv_update_option( 'paypal_email', sanitize_email( $user_info->emails[0]->value ) );
860
+                    wpinv_update_option( 'paypal_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
861
+                    set_transient( 'getpaid_paypal_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
862
+                    getpaid_admin()->show_success( __( 'Successfully connected your PayPal account', 'invoicing' ) );
863
+                }
864
+            }
865
+        }
866
+
867
+        $redirect = empty( $data['redirect'] ) ? admin_url( 'admin.php?page=wpinv-settings&tab=gateways&section=paypal' ) : urldecode( $data['redirect'] );
868
+
869
+        if ( isset( $data['step'] ) ) {
870
+            $redirect = add_query_arg( 'step', $data['step'], $redirect );
871
+        }
872
+        wp_redirect( $redirect );
873
+        exit;
874
+    }
875 875
 
876 876
 }
Please login to merge, or discard this patch.
Spacing   +185 added lines, -185 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
  * Paypal Payment Gateway class.
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @var array
26 26
 	 */
27
-    protected $supports = array( 'subscription', 'sandbox', 'single_subscription_group', 'refunds' );
27
+    protected $supports = array('subscription', 'sandbox', 'single_subscription_group', 'refunds');
28 28
 
29 29
     /**
30 30
 	 * Payment method order.
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @var array
61 61
 	 */
62
-	public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' );
62
+	public $currencies = array('AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR');
63 63
 
64 64
     /**
65 65
 	 * URL to view a transaction.
@@ -81,22 +81,22 @@  discard block
 block discarded – undo
81 81
 	public function __construct() {
82 82
 		parent::__construct();
83 83
 
84
-        $this->title                = __( 'PayPal Standard', 'invoicing' );
85
-        $this->method_title         = __( 'PayPal Standard', 'invoicing' );
86
-        $this->checkout_button_text = __( 'Proceed to PayPal', 'invoicing' );
87
-        $this->notify_url           = wpinv_get_ipn_url( $this->id );
88
-
89
-		add_filter( 'wpinv_subscription_cancel_url', array( $this, 'filter_cancel_subscription_url' ), 10, 2 );
90
-		add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 );
91
-		add_filter( 'getpaid_get_paypal_connect_url', array( $this, 'maybe_get_connect_url' ), 10, 2 );
92
-		add_action( 'getpaid_authenticated_admin_action_connect_paypal', array( $this, 'connect_paypal' ) );
93
-		add_action( 'wpinv_paypal_connect', array( $this, 'display_connect_buttons' ) );
94
-
95
-		if ( $this->enabled ) {
96
-			add_filter( 'getpaid_paypal_sandbox_notice', array( $this, 'sandbox_notice' ) );
97
-			add_action( 'getpaid_paypal_subscription_cancelled', array( $this, 'subscription_cancelled' ) );
98
-			add_action( 'getpaid_delete_subscription', array( $this, 'subscription_cancelled' ) );
99
-			add_action( 'getpaid_refund_invoice_remotely', array( $this, 'refund_invoice' ) );
84
+        $this->title                = __('PayPal Standard', 'invoicing');
85
+        $this->method_title         = __('PayPal Standard', 'invoicing');
86
+        $this->checkout_button_text = __('Proceed to PayPal', 'invoicing');
87
+        $this->notify_url           = wpinv_get_ipn_url($this->id);
88
+
89
+		add_filter('wpinv_subscription_cancel_url', array($this, 'filter_cancel_subscription_url'), 10, 2);
90
+		add_filter('getpaid_paypal_args', array($this, 'process_subscription'), 10, 2);
91
+		add_filter('getpaid_get_paypal_connect_url', array($this, 'maybe_get_connect_url'), 10, 2);
92
+		add_action('getpaid_authenticated_admin_action_connect_paypal', array($this, 'connect_paypal'));
93
+		add_action('wpinv_paypal_connect', array($this, 'display_connect_buttons'));
94
+
95
+		if ($this->enabled) {
96
+			add_filter('getpaid_paypal_sandbox_notice', array($this, 'sandbox_notice'));
97
+			add_action('getpaid_paypal_subscription_cancelled', array($this, 'subscription_cancelled'));
98
+			add_action('getpaid_delete_subscription', array($this, 'subscription_cancelled'));
99
+			add_action('getpaid_refund_invoice_remotely', array($this, 'refund_invoice'));
100 100
 		}
101 101
     }
102 102
 
@@ -109,16 +109,16 @@  discard block
 block discarded – undo
109 109
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
110 110
 	 * @return array
111 111
 	 */
112
-	public function process_payment( $invoice, $submission_data, $submission ) {
112
+	public function process_payment($invoice, $submission_data, $submission) {
113 113
 
114 114
         // Get redirect url.
115
-        $paypal_redirect = $this->get_request_url( $invoice );
115
+        $paypal_redirect = $this->get_request_url($invoice);
116 116
 
117 117
         // Add a note about the request url.
118 118
         $invoice->add_note(
119 119
             sprintf(
120
-                __( 'Redirecting to PayPal: %s', 'invoicing' ),
121
-                esc_url( $paypal_redirect )
120
+                __('Redirecting to PayPal: %s', 'invoicing'),
121
+                esc_url($paypal_redirect)
122 122
             ),
123 123
             false,
124 124
             false,
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
         );
127 127
 
128 128
         // Redirect to PayPal
129
-        wp_redirect( $paypal_redirect );
129
+        wp_redirect($paypal_redirect);
130 130
         exit;
131 131
 
132 132
     }
@@ -137,21 +137,21 @@  discard block
 block discarded – undo
137 137
 	 * @param  WPInv_Invoice $invoice Invoice object.
138 138
 	 * @return string
139 139
 	 */
140
-	public function get_request_url( $invoice ) {
140
+	public function get_request_url($invoice) {
141 141
 
142 142
         // Endpoint for this request
143
-		$this->endpoint    = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
143
+		$this->endpoint = $this->is_sandbox($invoice) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
144 144
 
145 145
         // Retrieve paypal args.
146
-        $paypal_args       = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' );
146
+        $paypal_args = map_deep($this->get_paypal_args($invoice), 'urlencode');
147 147
 
148
-        if ( $invoice->is_recurring() ) {
148
+        if ($invoice->is_recurring()) {
149 149
             $paypal_args['bn'] = 'GetPaid_Subscribe_WPS_US';
150 150
         } else {
151 151
             $paypal_args['bn'] = 'GetPaid_ShoppingCart_WPS_US';
152 152
         }
153 153
 
154
-        return add_query_arg( $paypal_args, $this->endpoint );
154
+        return add_query_arg($paypal_args, $this->endpoint);
155 155
 
156 156
 	}
157 157
 
@@ -161,25 +161,25 @@  discard block
 block discarded – undo
161 161
 	 * @param  WPInv_Invoice $invoice Invoice object.
162 162
 	 * @return array
163 163
 	 */
164
-	protected function get_paypal_args( $invoice ) {
164
+	protected function get_paypal_args($invoice) {
165 165
 
166 166
         // Whether or not to send the line items as one item.
167
-		$force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', true, $invoice );
167
+		$force_one_line_item = apply_filters('getpaid_paypal_force_one_line_item', true, $invoice);
168 168
 
169
-		if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) {
169
+		if ($invoice->is_recurring() || (wpinv_use_taxes() && wpinv_prices_include_tax())) {
170 170
 			$force_one_line_item = true;
171 171
 		}
172 172
 
173 173
 		$paypal_args = apply_filters(
174 174
 			'getpaid_paypal_args',
175 175
 			array_merge(
176
-				$this->get_transaction_args( $invoice ),
177
-				$this->get_line_item_args( $invoice, $force_one_line_item )
176
+				$this->get_transaction_args($invoice),
177
+				$this->get_line_item_args($invoice, $force_one_line_item)
178 178
 			),
179 179
 			$invoice
180 180
 		);
181 181
 
182
-		return $this->fix_request_length( $invoice, $paypal_args );
182
+		return $this->fix_request_length($invoice, $paypal_args);
183 183
     }
184 184
 
185 185
     /**
@@ -188,9 +188,9 @@  discard block
 block discarded – undo
188 188
 	 * @param WPInv_Invoice $invoice Invoice object.
189 189
 	 * @return array
190 190
 	 */
191
-	protected function get_transaction_args( $invoice ) {
191
+	protected function get_transaction_args($invoice) {
192 192
 
193
-		$email = $this->is_sandbox( $invoice ) ? wpinv_get_option( 'paypal_sandbox_email', wpinv_get_option( 'paypal_email', '' ) ) : wpinv_get_option( 'paypal_email', '' );
193
+		$email = $this->is_sandbox($invoice) ? wpinv_get_option('paypal_sandbox_email', wpinv_get_option('paypal_email', '')) : wpinv_get_option('paypal_email', '');
194 194
 		return array(
195 195
             'cmd'           => '_cart',
196 196
             'business'      => $email,
@@ -201,16 +201,16 @@  discard block
 block discarded – undo
201 201
             'rm'            => is_ssl() ? 2 : 1,
202 202
             'upload'        => 1,
203 203
             'currency_code' => $invoice->get_currency(), // https://developer.paypal.com/docs/nvp-soap-api/currency-codes/#paypal
204
-            'return'        => esc_url_raw( $this->get_return_url( $invoice ) ),
205
-            'cancel_return' => esc_url_raw( $invoice->get_checkout_payment_url() ),
206
-            'notify_url'    => getpaid_limit_length( $this->notify_url, 255 ),
207
-            'invoice'       => getpaid_limit_length( $invoice->get_number(), 127 ),
204
+            'return'        => esc_url_raw($this->get_return_url($invoice)),
205
+            'cancel_return' => esc_url_raw($invoice->get_checkout_payment_url()),
206
+            'notify_url'    => getpaid_limit_length($this->notify_url, 255),
207
+            'invoice'       => getpaid_limit_length($invoice->get_number(), 127),
208 208
             'custom'        => $invoice->get_id(),
209
-            'first_name'    => getpaid_limit_length( $invoice->get_first_name(), 32 ),
210
-            'last_name'     => getpaid_limit_length( $invoice->get_last_name(), 64 ),
211
-            'country'       => getpaid_limit_length( $invoice->get_country(), 2 ),
212
-            'email'         => getpaid_limit_length( $invoice->get_email(), 127 ),
213
-            'cbt'           => get_bloginfo( 'name' ),
209
+            'first_name'    => getpaid_limit_length($invoice->get_first_name(), 32),
210
+            'last_name'     => getpaid_limit_length($invoice->get_last_name(), 64),
211
+            'country'       => getpaid_limit_length($invoice->get_country(), 2),
212
+            'email'         => getpaid_limit_length($invoice->get_email(), 127),
213
+            'cbt'           => get_bloginfo('name'),
214 214
         );
215 215
 
216 216
     }
@@ -222,30 +222,30 @@  discard block
 block discarded – undo
222 222
 	 * @param  bool     $force_one_line_item Create only one item for this invoice.
223 223
 	 * @return array
224 224
 	 */
225
-	protected function get_line_item_args( $invoice, $force_one_line_item = false ) {
225
+	protected function get_line_item_args($invoice, $force_one_line_item = false) {
226 226
 
227 227
         // Maybe send invoice as a single item.
228
-		if ( $force_one_line_item ) {
229
-            return $this->get_line_item_args_single_item( $invoice );
228
+		if ($force_one_line_item) {
229
+            return $this->get_line_item_args_single_item($invoice);
230 230
         }
231 231
 
232 232
         // Send each line item individually.
233 233
         $line_item_args = array();
234 234
 
235 235
         // Prepare line items.
236
-        $this->prepare_line_items( $invoice );
236
+        $this->prepare_line_items($invoice);
237 237
 
238 238
         // Add taxes to the cart
239
-        if ( wpinv_use_taxes() && $invoice->is_taxable() ) {
240
-            $line_item_args['tax_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_tax(), 2 );
239
+        if (wpinv_use_taxes() && $invoice->is_taxable()) {
240
+            $line_item_args['tax_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_tax(), 2);
241 241
         }
242 242
 
243 243
         // Add discount.
244
-        if ( $invoice->get_total_discount() > 0 ) {
245
-            $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 );
244
+        if ($invoice->get_total_discount() > 0) {
245
+            $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_discount(), 2);
246 246
         }
247 247
 
248
-		return array_merge( $line_item_args, $this->get_line_items() );
248
+		return array_merge($line_item_args, $this->get_line_items());
249 249
 
250 250
     }
251 251
 
@@ -255,11 +255,11 @@  discard block
 block discarded – undo
255 255
 	 * @param  WPInv_Invoice $invoice Invoice object.
256 256
 	 * @return array
257 257
 	 */
258
-	protected function get_line_item_args_single_item( $invoice ) {
258
+	protected function get_line_item_args_single_item($invoice) {
259 259
 		$this->delete_line_items();
260 260
 
261
-        $item_name = wp_sprintf( __( 'Invoice %s', 'invoicing' ), $invoice->get_number() );
262
-		$this->add_line_item( $item_name, 1, wpinv_round_amount( (float) $invoice->get_total(), 2, true ), $invoice->get_id() );
261
+        $item_name = wp_sprintf(__('Invoice %s', 'invoicing'), $invoice->get_number());
262
+		$this->add_line_item($item_name, 1, wpinv_round_amount((float) $invoice->get_total(), 2, true), $invoice->get_id());
263 263
 
264 264
 		return $this->get_line_items();
265 265
     }
@@ -283,19 +283,19 @@  discard block
 block discarded – undo
283 283
 	 *
284 284
 	 * @param  WPInv_Invoice $invoice Invoice object.
285 285
 	 */
286
-	protected function prepare_line_items( $invoice ) {
286
+	protected function prepare_line_items($invoice) {
287 287
 		$this->delete_line_items();
288 288
 
289 289
 		// Items.
290
-		foreach ( $invoice->get_items() as $item ) {
290
+		foreach ($invoice->get_items() as $item) {
291 291
 			$amount   = $item->get_price();
292 292
 			$quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity();
293
-			$this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() );
293
+			$this->add_line_item($item->get_raw_name(), $quantity, $amount, $item->get_id());
294 294
         }
295 295
 
296 296
         // Fees.
297
-		foreach ( $invoice->get_fees() as $fee => $data ) {
298
-            $this->add_line_item( $fee, 1, wpinv_sanitize_amount( $data['initial_fee'] ) );
297
+		foreach ($invoice->get_fees() as $fee => $data) {
298
+            $this->add_line_item($fee, 1, wpinv_sanitize_amount($data['initial_fee']));
299 299
         }
300 300
 
301 301
     }
@@ -308,20 +308,20 @@  discard block
 block discarded – undo
308 308
 	 * @param  float  $amount Amount.
309 309
 	 * @param  string $item_number Item number.
310 310
 	 */
311
-	protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) {
312
-		$index = ( count( $this->line_items ) / 4 ) + 1;
311
+	protected function add_line_item($item_name, $quantity = 1, $amount = 0.0, $item_number = '') {
312
+		$index = (count($this->line_items) / 4) + 1;
313 313
 
314 314
 		/**
315 315
 		 * Prevent error "Things don't appear to be working at the moment. (https://www.sandbox.paypal.com/webapps/hermes/error)"
316 316
 		 */
317
-		$item_name = str_replace( "#", "", $item_name );
317
+		$item_name = str_replace("#", "", $item_name);
318 318
 
319 319
 		$item = apply_filters(
320 320
 			'getpaid_paypal_line_item',
321 321
 			array(
322
-				'item_name'   => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
322
+				'item_name'   => html_entity_decode(getpaid_limit_length($item_name ? wp_strip_all_tags($item_name) : __('Item', 'invoicing'), 127), ENT_NOQUOTES, 'UTF-8'),
323 323
 				'quantity'    => (float) $quantity,
324
-				'amount'      => wpinv_sanitize_amount( (float) $amount, 2 ),
324
+				'amount'      => wpinv_sanitize_amount((float) $amount, 2),
325 325
 				'item_number' => $item_number,
326 326
 			),
327 327
 			$item_name,
@@ -330,12 +330,12 @@  discard block
 block discarded – undo
330 330
 			$item_number
331 331
 		);
332 332
 
333
-		$this->line_items[ 'item_name_' . $index ]   = getpaid_limit_length( $item['item_name'], 127 );
334
-        $this->line_items[ 'quantity_' . $index ]    = $item['quantity'];
333
+		$this->line_items['item_name_' . $index] = getpaid_limit_length($item['item_name'], 127);
334
+        $this->line_items['quantity_' . $index] = $item['quantity'];
335 335
 
336 336
         // The price or amount of the product, service, or contribution, not including shipping, handling, or tax.
337
-		$this->line_items[ 'amount_' . $index ]      = $item['amount'] * $item['quantity'];
338
-		$this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 );
337
+		$this->line_items['amount_' . $index]      = $item['amount'] * $item['quantity'];
338
+		$this->line_items['item_number_' . $index] = getpaid_limit_length($item['item_number'], 127);
339 339
     }
340 340
 
341 341
     /**
@@ -347,19 +347,19 @@  discard block
 block discarded – undo
347 347
 	 * @param array    $paypal_args Arguments sent to Paypal in the request.
348 348
 	 * @return array
349 349
 	 */
350
-	protected function fix_request_length( $invoice, $paypal_args ) {
350
+	protected function fix_request_length($invoice, $paypal_args) {
351 351
 		$max_paypal_length = 2083;
352
-		$query_candidate   = http_build_query( $paypal_args, '', '&' );
352
+		$query_candidate   = http_build_query($paypal_args, '', '&');
353 353
 
354
-		if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) {
354
+		if (strlen($this->endpoint . $query_candidate) <= $max_paypal_length) {
355 355
 			return $paypal_args;
356 356
 		}
357 357
 
358 358
 		return apply_filters(
359 359
 			'getpaid_paypal_args',
360 360
 			array_merge(
361
-				$this->get_transaction_args( $invoice ),
362
-				$this->get_line_item_args( $invoice, true )
361
+				$this->get_transaction_args($invoice),
362
+				$this->get_line_item_args($invoice, true)
363 363
 			),
364 364
 			$invoice
365 365
 		);
@@ -372,10 +372,10 @@  discard block
 block discarded – undo
372 372
 	 * @param  array $paypal_args PayPal args.
373 373
 	 * @param  WPInv_Invoice    $invoice Invoice object.
374 374
 	 */
375
-	public function process_subscription( $paypal_args, $invoice ) {
375
+	public function process_subscription($paypal_args, $invoice) {
376 376
 
377 377
         // Make sure this is a subscription.
378
-        if ( ! $invoice->is_recurring() || ! $subscription = getpaid_get_invoice_subscription( $invoice ) ) {
378
+        if (!$invoice->is_recurring() || !$subscription = getpaid_get_invoice_subscription($invoice)) {
379 379
             return $paypal_args;
380 380
         }
381 381
 
@@ -383,23 +383,23 @@  discard block
 block discarded – undo
383 383
         $paypal_args['cmd'] = '_xclick-subscriptions';
384 384
 
385 385
         // Subscription name.
386
-        $paypal_args['item_name'] = wp_sprintf( __( 'Invoice %s', 'invoicing' ), $invoice->get_number() );
386
+        $paypal_args['item_name'] = wp_sprintf(__('Invoice %s', 'invoicing'), $invoice->get_number());
387 387
 
388 388
         // Get subscription args.
389
-        $period                 = strtoupper( substr( $subscription->get_period(), 0, 1 ) );
389
+        $period                 = strtoupper(substr($subscription->get_period(), 0, 1));
390 390
         $interval               = (int) $subscription->get_frequency();
391 391
         $bill_times             = (int) $subscription->get_bill_times();
392
-        $initial_amount         = (float) wpinv_sanitize_amount( $invoice->get_initial_total(), 2 );
393
-        $recurring_amount       = (float) wpinv_sanitize_amount( $invoice->get_recurring_total(), 2 );
394
-        $subscription_item      = $invoice->get_recurring( true );
392
+        $initial_amount         = (float) wpinv_sanitize_amount($invoice->get_initial_total(), 2);
393
+        $recurring_amount       = (float) wpinv_sanitize_amount($invoice->get_recurring_total(), 2);
394
+        $subscription_item      = $invoice->get_recurring(true);
395 395
 
396 396
 		// Convert 365 days to 1 year.
397
-		if ( 'D' == $period && 365 == $interval ) {
397
+		if ('D' == $period && 365 == $interval) {
398 398
 			$period = 'Y';
399 399
 			$interval = 1;
400 400
 		}
401 401
 
402
-        if ( $subscription_item->has_free_trial() ) {
402
+        if ($subscription_item->has_free_trial()) {
403 403
 
404 404
             $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount;
405 405
 
@@ -409,28 +409,28 @@  discard block
 block discarded – undo
409 409
 			// Trial period.
410 410
 			$paypal_args['t1'] = $subscription_item->get_trial_period();
411 411
 
412
-        } elseif ( $initial_amount != $recurring_amount ) {
412
+        } elseif ($initial_amount != $recurring_amount) {
413 413
 
414 414
             // No trial period, but initial amount includes a sign-up fee and/or other items, so charge it as a separate period.
415 415
 
416
-            if ( 1 == $bill_times ) {
416
+            if (1 == $bill_times) {
417 417
                 $param_number = 3;
418 418
             } else {
419 419
                 $param_number = 1;
420 420
             }
421 421
 
422
-            $paypal_args[ 'a' . $param_number ] = $initial_amount ? $initial_amount : 0;
422
+            $paypal_args['a' . $param_number] = $initial_amount ? $initial_amount : 0;
423 423
 
424 424
             // Sign Up interval
425
-            $paypal_args[ 'p' . $param_number ] = $interval;
425
+            $paypal_args['p' . $param_number] = $interval;
426 426
 
427 427
             // Sign Up unit of duration
428
-            $paypal_args[ 't' . $param_number ] = $period;
428
+            $paypal_args['t' . $param_number] = $period;
429 429
 
430 430
         }
431 431
 
432 432
         // We have a recurring payment
433
-		if ( ! isset( $param_number ) || 1 == $param_number ) {
433
+		if (!isset($param_number) || 1 == $param_number) {
434 434
 
435 435
 			// Subscription price
436 436
 			$paypal_args['a3'] = $recurring_amount;
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
         }
445 445
 
446 446
         // Recurring payments
447
-		if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) {
447
+		if (1 == $bill_times || ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial() && 2 == $bill_times)) {
448 448
 
449 449
 			// Non-recurring payments
450 450
 			$paypal_args['src'] = 0;
@@ -453,15 +453,15 @@  discard block
 block discarded – undo
453 453
 
454 454
 			$paypal_args['src'] = 1;
455 455
 
456
-			if ( $bill_times > 0 ) {
456
+			if ($bill_times > 0) {
457 457
 
458 458
 				// An initial period is being used to charge a sign-up fee
459
-				if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) {
459
+				if ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial()) {
460 460
 					$bill_times--;
461 461
 				}
462 462
 
463 463
                 // Make sure it's not over the max of 52
464
-                $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 );
464
+                $paypal_args['srt'] = ($bill_times <= 52 ? absint($bill_times) : 52);
465 465
 
466 466
 			}
467 467
         }
@@ -470,10 +470,10 @@  discard block
 block discarded – undo
470 470
         $paypal_args['rm'] = 2;
471 471
 
472 472
         // Get rid of redudant items.
473
-        foreach ( array( 'item_name_1', 'quantity_1', 'amount_1', 'item_number_1' ) as $arg ) {
473
+        foreach (array('item_name_1', 'quantity_1', 'amount_1', 'item_number_1') as $arg) {
474 474
 
475
-            if ( isset( $paypal_args[ $arg ] ) ) {
476
-                unset( $paypal_args[ $arg ] );
475
+            if (isset($paypal_args[$arg])) {
476
+                unset($paypal_args[$arg]);
477 477
             }
478 478
 		}
479 479
 
@@ -491,20 +491,20 @@  discard block
 block discarded – undo
491 491
 	 * @since 2.8.24
492 492
 	 * @param WPInv_Invoice $invoice Invoice object.
493 493
 	 */
494
-	public function refund_invoice( $invoice ) {
494
+	public function refund_invoice($invoice) {
495 495
 
496
-		if ( $invoice->get_gateway() !== $this->id ) {
496
+		if ($invoice->get_gateway() !== $this->id) {
497 497
 			return;
498 498
 		}
499 499
 
500
-		$mode	= $this->is_sandbox( $invoice ) ? 'sandbox' : 'live';
501
-		$result = GetPaid_PayPal_API::refund_capture( $invoice->get_transaction_id(), array(), $mode );
500
+		$mode = $this->is_sandbox($invoice) ? 'sandbox' : 'live';
501
+		$result = GetPaid_PayPal_API::refund_capture($invoice->get_transaction_id(), array(), $mode);
502 502
 
503
-		if ( is_wp_error( $result ) ) {
503
+		if (is_wp_error($result)) {
504 504
 			$invoice->add_system_note(
505 505
 				sprintf(
506 506
 					// translators: %s is the error message.
507
-					__( 'An error occured while trying to refund invoice #%1$s in PayPal: %2$s', 'invoicing' ),
507
+					__('An error occured while trying to refund invoice #%1$s in PayPal: %2$s', 'invoicing'),
508 508
 					$invoice->get_id(),
509 509
 					$result->get_error_message()
510 510
 				)
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
 			$invoice->add_system_note(
514 514
 				sprintf(
515 515
 					// translators: %s is the refund ID.
516
-					__( 'Successfully refunded invoice #%1$s in PayPal. Refund ID: %2$s', 'invoicing' ),
516
+					__('Successfully refunded invoice #%1$s in PayPal. Refund ID: %2$s', 'invoicing'),
517 517
 					$invoice->get_id(),
518 518
 					$result->id
519 519
 				)
@@ -527,50 +527,50 @@  discard block
 block discarded – undo
527 527
 	 * @since 2.8.24
528 528
 	 * @param WPInv_Subscription $subscription Subscription object.
529 529
 	 */
530
-	public function subscription_cancelled( $subscription ) {
530
+	public function subscription_cancelled($subscription) {
531 531
 
532
-		if ( $subscription->get_gateway() != $this->id ) {
532
+		if ($subscription->get_gateway() != $this->id) {
533 533
 			return;
534 534
 		}
535 535
 
536 536
 		$invoice = $subscription->get_parent_invoice();
537 537
 
538 538
 		// Abort if the parent invoice does not exist.
539
-		if ( ! $invoice->exists() ) {
539
+		if (!$invoice->exists()) {
540 540
 			return;
541 541
 		}
542 542
 
543
-		$mode	= $this->is_sandbox( $invoice ) ? 'sandbox' : 'live';
543
+		$mode = $this->is_sandbox($invoice) ? 'sandbox' : 'live';
544 544
 		$result = GetPaid_PayPal_API::cancel_subscription( 
545 545
 			$invoice->get_remote_subscription_id(), 
546 546
 			array(
547
-				'reason' => __(' Customer requested cancellation', 'invoicing' ),
547
+				'reason' => __(' Customer requested cancellation', 'invoicing'),
548 548
 			), 
549 549
 			$mode 
550 550
 		);
551 551
 
552
-		if ( is_wp_error( $result ) ) {
552
+		if (is_wp_error($result)) {
553 553
 
554 554
 			$error = sprintf(
555 555
 				// translators: %s is the subscription ID.
556
-				__( 'An error occured while trying to cancel subscription #%s in PayPal.', 'invoicing' ),
556
+				__('An error occured while trying to cancel subscription #%s in PayPal.', 'invoicing'),
557 557
 				$subscription->get_id()
558 558
 			);
559 559
 
560
-			getpaid_admin()->show_error( $error . ' ' . $result->get_error_message() );
560
+			getpaid_admin()->show_error($error . ' ' . $result->get_error_message());
561 561
 
562
-			if ( ! is_admin() ) {
563
-				wpinv_set_error( $result->get_error_code(), $error );
562
+			if (!is_admin()) {
563
+				wpinv_set_error($result->get_error_code(), $error);
564 564
 			}
565 565
 
566 566
 			return;
567 567
 		}
568 568
 
569
-		if ( is_admin() ) {
569
+		if (is_admin()) {
570 570
 			getpaid_admin()->show_success(
571 571
 				sprintf(
572 572
 					// translators: %s is the subscription ID.
573
-					__( 'Successfully cancelled subscription #%s in PayPal.', 'invoicing' ),
573
+					__('Successfully cancelled subscription #%s in PayPal.', 'invoicing'),
574 574
 					$subscription->get_id()
575 575
 				)
576 576
 			);
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 	 * @return void
585 585
 	 */
586 586
 	public function verify_ipn() {
587
-        new GetPaid_Paypal_Gateway_IPN_Handler( $this );
587
+        new GetPaid_Paypal_Gateway_IPN_Handler($this);
588 588
     }
589 589
 
590 590
     /**
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
     public function sandbox_notice() {
594 594
 
595 595
         return sprintf(
596
-			__( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %1$sPayPal Sandbox Testing Guide%2$s for more details.', 'invoicing' ),
596
+			__('SANDBOX ENABLED. You can use sandbox testing accounts only. See the %1$sPayPal Sandbox Testing Guide%2$s for more details.', 'invoicing'),
597 597
 			'<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">',
598 598
 			'</a>'
599 599
 		);
@@ -605,41 +605,41 @@  discard block
 block discarded – undo
605 605
 	 *
606 606
 	 * @param array $admin_settings
607 607
 	 */
608
-	public function admin_settings( $admin_settings ) {
608
+	public function admin_settings($admin_settings) {
609 609
 
610 610
         $currencies = sprintf(
611
-            __( 'Supported Currencies: %s', 'invoicing' ),
612
-            implode( ', ', $this->currencies )
611
+            __('Supported Currencies: %s', 'invoicing'),
612
+            implode(', ', $this->currencies)
613 613
         );
614 614
 
615 615
         $admin_settings['paypal_active']['desc'] .= " ($currencies)";
616
-        $admin_settings['paypal_desc']['std']     = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' );
616
+        $admin_settings['paypal_desc']['std']     = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing');
617 617
 
618 618
 		// Access tokens.
619
-		$live_email      = wpinv_get_option( 'paypal_email' );
620
-		$sandbox_email   = wpinv_get_option( 'paypal_sandbox_email' );
619
+		$live_email      = wpinv_get_option('paypal_email');
620
+		$sandbox_email   = wpinv_get_option('paypal_sandbox_email');
621 621
 
622 622
 		$admin_settings['paypal_connect'] = array(
623 623
 			'type' => 'hook',
624 624
 			'id'   => 'paypal_connect',
625
-			'name' => __( 'Connect to PayPal', 'invoicing' ),
625
+			'name' => __('Connect to PayPal', 'invoicing'),
626 626
 		);
627 627
 
628 628
         $admin_settings['paypal_email'] = array(
629 629
             'type'  => 'text',
630 630
 			'class' => 'live-auth-data',
631 631
             'id'    => 'paypal_email',
632
-            'name'  => __( 'Live Email Address', 'invoicing' ),
633
-            'desc'  => __( 'The email address of your PayPal account.', 'invoicing' ),
632
+            'name'  => __('Live Email Address', 'invoicing'),
633
+            'desc'  => __('The email address of your PayPal account.', 'invoicing'),
634 634
         );
635 635
 
636 636
 		$admin_settings['paypal_sandbox_email'] = array(
637 637
             'type'  => 'text',
638 638
 			'class' => 'sandbox-auth-data',
639 639
             'id'    => 'paypal_sandbox_email',
640
-            'name'  => __( 'Sandbox Email Address', 'invoicing' ),
641
-            'desc'  => __( 'The email address of your sandbox PayPal account.', 'invoicing' ),
642
-			'std'   => wpinv_get_option( 'paypal_email', '' ),
640
+            'name'  => __('Sandbox Email Address', 'invoicing'),
641
+            'desc'  => __('The email address of your sandbox PayPal account.', 'invoicing'),
642
+			'std'   => wpinv_get_option('paypal_email', ''),
643 643
         );
644 644
 
645 645
 		// Client ID and secret.
@@ -647,41 +647,41 @@  discard block
 block discarded – undo
647 647
 			'type'  => 'text',
648 648
 			'class' => 'live-auth-data',
649 649
 			'id'    => 'paypal_client_id',
650
-			'name'  => __( 'Live Client ID', 'invoicing' ),
651
-			'desc'  => __( 'The client ID of your PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing' ),
650
+			'name'  => __('Live Client ID', 'invoicing'),
651
+			'desc'  => __('The client ID of your PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing'),
652 652
 		);
653 653
 
654 654
 		$admin_settings['paypal_sandbox_client_id'] = array(
655 655
 			'type'  => 'text',
656 656
 			'class' => 'sandbox-auth-data',
657 657
 			'id'    => 'paypal_sandbox_client_id',
658
-			'name'  => __( 'Sandbox Client ID', 'invoicing' ),
659
-			'desc'  => __( 'The client ID of your sandbox PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing' ),
660
-			'std'   => wpinv_get_option( 'paypal_client_id', '' ),
658
+			'name'  => __('Sandbox Client ID', 'invoicing'),
659
+			'desc'  => __('The client ID of your sandbox PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing'),
660
+			'std'   => wpinv_get_option('paypal_client_id', ''),
661 661
 		);
662 662
 
663 663
 		$admin_settings['paypal_secret'] = array(
664 664
 			'type'  => 'text',
665 665
 			'class' => 'live-auth-data',
666 666
 			'id'    => 'paypal_secret',
667
-			'name'  => __( 'Live Secret', 'invoicing' ),
668
-			'desc'  => __( 'The secret of your PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing' ),
667
+			'name'  => __('Live Secret', 'invoicing'),
668
+			'desc'  => __('The secret of your PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing'),
669 669
 		);
670 670
 
671 671
 		$admin_settings['paypal_sandbox_secret'] = array(
672 672
 			'type'  => 'text',
673 673
 			'class' => 'sandbox-auth-data',
674 674
 			'id'    => 'paypal_sandbox_secret',
675
-			'name'  => __( 'Sandbox Secret', 'invoicing' ),
676
-			'desc'  => __( 'The secret of your sandbox PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing' ),
675
+			'name'  => __('Sandbox Secret', 'invoicing'),
676
+			'desc'  => __('The secret of your sandbox PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing'),
677 677
 		);
678 678
 
679 679
         $admin_settings['paypal_ipn_url'] = array(
680 680
             'type'     => 'ipn_url',
681 681
             'id'       => 'paypal_ipn_url',
682
-            'name'     => __( 'IPN Url', 'invoicing' ),
682
+            'name'     => __('IPN Url', 'invoicing'),
683 683
             'std'      => $this->notify_url,
684
-            'desc'     => __( "If you've not enabled IPNs in your paypal account, use the above URL to enable them.", 'invoicing' ) . ' <a href="https://developer.paypal.com/docs/api-basics/notifications/ipn/"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>',
684
+            'desc'     => __("If you've not enabled IPNs in your paypal account, use the above URL to enable them.", 'invoicing') . ' <a href="https://developer.paypal.com/docs/api-basics/notifications/ipn/"><em>' . __('Learn more.', 'invoicing') . '</em></a>',
685 685
             'readonly' => true,
686 686
         );
687 687
 
@@ -694,9 +694,9 @@  discard block
 block discarded – undo
694 694
 	 * @param string $url
695 695
 	 * @param WPInv_Subscription $subscription
696 696
 	 */
697
-	public function filter_cancel_subscription_url( $url, $subscription ) {
697
+	public function filter_cancel_subscription_url($url, $subscription) {
698 698
 
699
-		if ( $this->id !== $subscription->get_gateway() ) {
699
+		if ($this->id !== $subscription->get_gateway()) {
700 700
 			return $url;
701 701
 		}
702 702
 
@@ -704,16 +704,16 @@  discard block
 block discarded – undo
704 704
 		$profile_id = $subscription->get_profile_id();
705 705
 
706 706
 		// Bail if no profile ID.
707
-		if ( empty( $profile_id ) ) {
707
+		if (empty($profile_id)) {
708 708
 			return $url;
709 709
 		}
710 710
 
711 711
 		$cancel_url = 'https://www.paypal.com/myaccount/autopay/connect/%s/cancel';
712
-		if ( $this->is_sandbox( $subscription->get_parent_payment() ) ) {
712
+		if ($this->is_sandbox($subscription->get_parent_payment())) {
713 713
 			$cancel_url = 'https://www.sandbox.paypal.com/myaccount/autopay/connect/%s/cancel';
714 714
 		}
715 715
 
716
-		return sprintf( $cancel_url, $profile_id );
716
+		return sprintf($cancel_url, $profile_id);
717 717
 	}
718 718
 
719 719
 	/**
@@ -723,8 +723,8 @@  discard block
 block discarded – undo
723 723
      * @param array $data
724 724
      * @return string
725 725
 	 */
726
-	public static function maybe_get_connect_url( $url = '', $data = array() ) {
727
-		return self::get_connect_url( false, urldecode( $data['redirect'] ) );
726
+	public static function maybe_get_connect_url($url = '', $data = array()) {
727
+		return self::get_connect_url(false, urldecode($data['redirect']));
728 728
 	}
729 729
 
730 730
 	/**
@@ -735,25 +735,25 @@  discard block
 block discarded – undo
735 735
 	 * @param string $redirect
736 736
      * @return string
737 737
 	 */
738
-	public static function get_connect_url( $is_sandbox, $redirect = '' ) {
738
+	public static function get_connect_url($is_sandbox, $redirect = '') {
739 739
 
740 740
         $redirect_url = add_query_arg(
741 741
             array(
742 742
                 'getpaid-admin-action' => 'connect_paypal',
743 743
                 'page'                 => 'wpinv-settings',
744
-                'live_mode'            => (int) empty( $is_sandbox ),
744
+                'live_mode'            => (int) empty($is_sandbox),
745 745
                 'tab'                  => 'gateways',
746 746
                 'section'              => 'paypal',
747
-                'getpaid-nonce'        => wp_create_nonce( 'getpaid-nonce' ),
748
-				'redirect'             => urlencode( $redirect ),
747
+                'getpaid-nonce'        => wp_create_nonce('getpaid-nonce'),
748
+				'redirect'             => urlencode($redirect),
749 749
             ),
750
-            admin_url( 'admin.php' )
750
+            admin_url('admin.php')
751 751
         );
752 752
 
753 753
         return add_query_arg(
754 754
             array(
755
-                'live_mode'    => (int) empty( $is_sandbox ),
756
-                'redirect_url' => urlencode( str_replace( '&amp;', '&', $redirect_url ) ),
755
+                'live_mode'    => (int) empty($is_sandbox),
756
+                'redirect_url' => urlencode(str_replace('&amp;', '&', $redirect_url)),
757 757
             ),
758 758
             'https://ayecode.io/oauth/paypal'
759 759
         );
@@ -769,10 +769,10 @@  discard block
 block discarded – undo
769 769
 
770 770
         ?>
771 771
 			<div class="wpinv-paypal-connect-live">
772
-				<a class="button button-primary" href="<?php echo esc_url( self::get_connect_url( false ) ); ?>"><?php esc_html_e( 'Connect to PayPal', 'invoicing' ); ?></a>
772
+				<a class="button button-primary" href="<?php echo esc_url(self::get_connect_url(false)); ?>"><?php esc_html_e('Connect to PayPal', 'invoicing'); ?></a>
773 773
 			</div>
774 774
 			<div class="wpinv-paypal-connect-sandbox">
775
-				<a class="button button-primary" href="<?php echo esc_url( self::get_connect_url( true ) ); ?>"><?php esc_html_e( 'Connect to PayPal Sandbox', 'invoicing' ); ?></a>
775
+				<a class="button button-primary" href="<?php echo esc_url(self::get_connect_url(true)); ?>"><?php esc_html_e('Connect to PayPal Sandbox', 'invoicing'); ?></a>
776 776
 			</div>
777 777
 
778 778
             <script>
@@ -813,26 +813,26 @@  discard block
 block discarded – undo
813 813
 	 * @param array $data Connection data.
814 814
 	 * @return void
815 815
 	 */
816
-	public function connect_paypal( $data ) {
816
+	public function connect_paypal($data) {
817 817
 
818 818
 		$sandbox      = $this->is_sandbox();
819
-		$data         = wp_unslash( $data );
820
-		$access_token = empty( $data['access_token'] ) ? '' : sanitize_text_field( $data['access_token'] );
819
+		$data         = wp_unslash($data);
820
+		$access_token = empty($data['access_token']) ? '' : sanitize_text_field($data['access_token']);
821 821
 
822
-		if ( isset( $data['live_mode'] ) ) {
823
-			$sandbox = empty( $data['live_mode'] );
822
+		if (isset($data['live_mode'])) {
823
+			$sandbox = empty($data['live_mode']);
824 824
 		}
825 825
 
826
-		wpinv_update_option( 'paypal_sandbox', (int) $sandbox );
827
-		wpinv_update_option( 'paypal_active', 1 );
826
+		wpinv_update_option('paypal_sandbox', (int) $sandbox);
827
+		wpinv_update_option('paypal_active', 1);
828 828
 
829
-		if ( ! empty( $data['error_description'] ) ) {
830
-			getpaid_admin()->show_error( wp_kses_post( urldecode( $data['error_description'] ) ) );
829
+		if (!empty($data['error_description'])) {
830
+			getpaid_admin()->show_error(wp_kses_post(urldecode($data['error_description'])));
831 831
 		} else {
832 832
 
833 833
 			// Retrieve the user info.
834 834
 			$user_info = wp_remote_get(
835
-				! $sandbox ? 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' : 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1',
835
+				!$sandbox ? 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' : 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1',
836 836
 				array(
837 837
 
838 838
 					'headers' => array(
@@ -843,33 +843,33 @@  discard block
 block discarded – undo
843 843
 				)
844 844
 			);
845 845
 
846
-			if ( is_wp_error( $user_info ) ) {
847
-				getpaid_admin()->show_error( wp_kses_post( $user_info->get_error_message() ) );
846
+			if (is_wp_error($user_info)) {
847
+				getpaid_admin()->show_error(wp_kses_post($user_info->get_error_message()));
848 848
 			} else {
849 849
 
850 850
 				// Create application.
851
-				$user_info = json_decode( wp_remote_retrieve_body( $user_info ) );
851
+				$user_info = json_decode(wp_remote_retrieve_body($user_info));
852 852
 
853
-				if ( $sandbox ) {
854
-					wpinv_update_option( 'paypal_sandbox_email', sanitize_email( $user_info->emails[0]->value ) );
855
-					wpinv_update_option( 'paypal_sandbox_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
856
-					set_transient( 'getpaid_paypal_sandbox_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
857
-					getpaid_admin()->show_success( __( 'Successfully connected your PayPal sandbox account', 'invoicing' ) );
853
+				if ($sandbox) {
854
+					wpinv_update_option('paypal_sandbox_email', sanitize_email($user_info->emails[0]->value));
855
+					wpinv_update_option('paypal_sandbox_refresh_token', sanitize_text_field(urldecode($data['refresh_token'])));
856
+					set_transient('getpaid_paypal_sandbox_access_token', sanitize_text_field(urldecode($data['access_token'])), (int) $data['expires_in']);
857
+					getpaid_admin()->show_success(__('Successfully connected your PayPal sandbox account', 'invoicing'));
858 858
 				} else {
859
-					wpinv_update_option( 'paypal_email', sanitize_email( $user_info->emails[0]->value ) );
860
-					wpinv_update_option( 'paypal_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
861
-					set_transient( 'getpaid_paypal_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
862
-					getpaid_admin()->show_success( __( 'Successfully connected your PayPal account', 'invoicing' ) );
859
+					wpinv_update_option('paypal_email', sanitize_email($user_info->emails[0]->value));
860
+					wpinv_update_option('paypal_refresh_token', sanitize_text_field(urldecode($data['refresh_token'])));
861
+					set_transient('getpaid_paypal_access_token', sanitize_text_field(urldecode($data['access_token'])), (int) $data['expires_in']);
862
+					getpaid_admin()->show_success(__('Successfully connected your PayPal account', 'invoicing'));
863 863
 				}
864 864
 			}
865 865
 		}
866 866
 
867
-		$redirect = empty( $data['redirect'] ) ? admin_url( 'admin.php?page=wpinv-settings&tab=gateways&section=paypal' ) : urldecode( $data['redirect'] );
867
+		$redirect = empty($data['redirect']) ? admin_url('admin.php?page=wpinv-settings&tab=gateways&section=paypal') : urldecode($data['redirect']);
868 868
 
869
-		if ( isset( $data['step'] ) ) {
870
-			$redirect = add_query_arg( 'step', $data['step'], $redirect );
869
+		if (isset($data['step'])) {
870
+			$redirect = add_query_arg('step', $data['step'], $redirect);
871 871
 		}
872
-		wp_redirect( $redirect );
872
+		wp_redirect($redirect);
873 873
 		exit;
874 874
 	}
875 875
 
Please login to merge, or discard this patch.
templates/payment-forms/elements/checkbox.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -13,19 +13,19 @@
 block discarded – undo
13 13
 $label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) );
14 14
 
15 15
 if ( ! empty( $required ) ) {
16
-	$label .= "<span class='text-danger'> *</span>";
16
+    $label .= "<span class='text-danger'> *</span>";
17 17
 }
18 18
 
19 19
 aui()->input(
20
-	array(
21
-		'type'      => 'checkbox',
22
-		'name'      => esc_attr( $id ),
23
-		'id'        => esc_attr( $element_id ),
24
-		'required'  => ! empty( $required ),
25
-		'label'     => $label,
26
-		'value'     => esc_attr__( 'Yes', 'invoicing' ),
27
-		'help_text' => empty( $description ) ? '' : wp_kses_post( $description ),
28
-		'class'     => $label_class
29
-	),
30
-	true
20
+    array(
21
+        'type'      => 'checkbox',
22
+        'name'      => esc_attr( $id ),
23
+        'id'        => esc_attr( $element_id ),
24
+        'required'  => ! empty( $required ),
25
+        'label'     => $label,
26
+        'value'     => esc_attr__( 'Yes', 'invoicing' ),
27
+        'help_text' => empty( $description ) ? '' : wp_kses_post( $description ),
28
+        'class'     => $label_class
29
+    ),
30
+    true
31 31
 );
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -7,24 +7,24 @@
 block discarded – undo
7 7
  * @version 2.8.24
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-$label = empty( $label ) ? '' : wp_kses_post( $label );
13
-$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) );
12
+$label = empty($label) ? '' : wp_kses_post($label);
13
+$label_class = sanitize_key(preg_replace('/[^A-Za-z0-9_-]/', '-', $label));
14 14
 
15
-if ( ! empty( $required ) ) {
15
+if (!empty($required)) {
16 16
 	$label .= "<span class='text-danger'> *</span>";
17 17
 }
18 18
 
19 19
 aui()->input(
20 20
 	array(
21 21
 		'type'      => 'checkbox',
22
-		'name'      => esc_attr( $id ),
23
-		'id'        => esc_attr( $element_id ),
24
-		'required'  => ! empty( $required ),
22
+		'name'      => esc_attr($id),
23
+		'id'        => esc_attr($element_id),
24
+		'required'  => !empty($required),
25 25
 		'label'     => $label,
26
-		'value'     => esc_attr__( 'Yes', 'invoicing' ),
27
-		'help_text' => empty( $description ) ? '' : wp_kses_post( $description ),
26
+		'value'     => esc_attr__('Yes', 'invoicing'),
27
+		'help_text' => empty($description) ? '' : wp_kses_post($description),
28 28
 		'class'     => $label_class
29 29
 	),
30 30
 	true
Please login to merge, or discard this patch.
templates/payment-forms/elements/address.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 defined( 'ABSPATH' ) || exit;
11 11
 
12 12
 if ( empty( $fields ) ) {
13
-	return;
13
+    return;
14 14
 }
15 15
 
16 16
 // A prefix for all ids (so that a form can be included in the same page multiple times).
@@ -18,12 +18,12 @@  discard block
 block discarded – undo
18 18
 
19 19
 // Prepare the user's country.
20 20
 if ( ! empty( $form->invoice ) ) {
21
-	$country = $form->invoice->get_country();
21
+    $country = $form->invoice->get_country();
22 22
 }
23 23
 
24 24
 if ( empty( $country ) ) {
25
-	$country = empty( $country ) ? getpaid_get_ip_country() : $country;
26
-	$country = empty( $country ) ? wpinv_get_default_country() : $country;
25
+    $country = empty( $country ) ? getpaid_get_ip_country() : $country;
26
+    $country = empty( $country ) ? wpinv_get_default_country() : $country;
27 27
 }
28 28
 
29 29
 // A prefix for all ids (so that a form can be included in the same page multiple times).
@@ -50,32 +50,32 @@  discard block
 block discarded – undo
50 50
 	<!-- Start Billing Address -->
51 51
 	<div class="getpaid-billing-address-wrapper">
52 52
 		<?php
53
-			$field_type = 'billing';
53
+            $field_type = 'billing';
54 54
 
55
-			wpinv_get_template( 'payment-forms/elements/address-fields.php', array( 'form' => $form, 'fields' => $fields, 'address_type' => $address_type, 'field_type' => $field_type, 'uniqid' => $uniqid, 'country' => $country ) );
55
+            wpinv_get_template( 'payment-forms/elements/address-fields.php', array( 'form' => $form, 'fields' => $fields, 'address_type' => $address_type, 'field_type' => $field_type, 'uniqid' => $uniqid, 'country' => $country ) );
56 56
 
57
-			do_action( 'getpaid_after_payment_form_billing_fields', $form );
58
-		?>
57
+            do_action( 'getpaid_after_payment_form_billing_fields', $form );
58
+        ?>
59 59
 	</div>
60 60
 	<!-- End Billing Address -->
61 61
 <?php endif; ?>
62 62
 
63 63
 <?php if ( 'both' === $address_type ) : ?>
64 64
 	<?php
65
-		aui()->input(
66
-			array(
67
-				'type'     => 'checkbox',
68
-				'name'     => 'same-shipping-address',
69
-				'id'       => "shipping-toggle$uniqid",
70
-				'required' => false,
71
-				'label'    => empty( $shipping_address_toggle ) ? esc_html__( 'Same billing & shipping address.', 'invoicing' ) : wp_kses_post( $shipping_address_toggle ),
72
-				'value'    => 1,
73
-				'checked'  => true,
74
-				'class'    => 'chkbox-same-shipping-address'
75
-			),
76
-			true
77
-		);
78
-	?>
65
+        aui()->input(
66
+            array(
67
+                'type'     => 'checkbox',
68
+                'name'     => 'same-shipping-address',
69
+                'id'       => "shipping-toggle$uniqid",
70
+                'required' => false,
71
+                'label'    => empty( $shipping_address_toggle ) ? esc_html__( 'Same billing & shipping address.', 'invoicing' ) : wp_kses_post( $shipping_address_toggle ),
72
+                'value'    => 1,
73
+                'checked'  => true,
74
+                'class'    => 'chkbox-same-shipping-address'
75
+            ),
76
+            true
77
+        );
78
+    ?>
79 79
 	<!-- Start Shipping Address Title -->
80 80
 	<h4 class="mb-3 getpaid-shipping-address-title">
81 81
 		<?php esc_html_e( 'Shipping Address', 'invoicing' ); ?>
@@ -87,12 +87,12 @@  discard block
 block discarded – undo
87 87
 	<!-- Start Shipping Address -->
88 88
 	<div class="getpaid-shipping-address-wrapper">
89 89
 		<?php
90
-			$field_type = 'shipping';
90
+            $field_type = 'shipping';
91 91
 
92
-			wpinv_get_template( 'payment-forms/elements/address-fields.php', array( 'form' => $form, 'fields' => $fields, 'address_type' => $address_type, 'field_type' => $field_type, 'uniqid' => $uniqid, 'country' => $country ) );
92
+            wpinv_get_template( 'payment-forms/elements/address-fields.php', array( 'form' => $form, 'fields' => $fields, 'address_type' => $address_type, 'field_type' => $field_type, 'uniqid' => $uniqid, 'country' => $country ) );
93 93
 
94
-			do_action( 'getpaid_after_payment_form_shipping_fields', $form );
95
-		?>
94
+            do_action( 'getpaid_after_payment_form_shipping_fields', $form );
95
+        ?>
96 96
 	</div>
97 97
 	<!-- End Shipping Address -->
98 98
 <?php endif; ?>
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -7,60 +7,60 @@  discard block
 block discarded – undo
7 7
  * @version 2.8.24
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-if ( empty( $fields ) ) {
12
+if (empty($fields)) {
13 13
 	return;
14 14
 }
15 15
 
16 16
 // A prefix for all ids (so that a form can be included in the same page multiple times).
17
-$uniqid = uniqid( '_' );
17
+$uniqid = uniqid('_');
18 18
 
19 19
 // Prepare the user's country.
20
-if ( ! empty( $form->invoice ) ) {
20
+if (!empty($form->invoice)) {
21 21
 	$country = $form->invoice->get_country();
22 22
 }
23 23
 
24
-if ( empty( $country ) ) {
25
-	$country = empty( $country ) ? getpaid_get_ip_country() : $country;
26
-	$country = empty( $country ) ? wpinv_get_default_country() : $country;
24
+if (empty($country)) {
25
+	$country = empty($country) ? getpaid_get_ip_country() : $country;
26
+	$country = empty($country) ? wpinv_get_default_country() : $country;
27 27
 }
28 28
 
29 29
 // A prefix for all ids (so that a form can be included in the same page multiple times).
30
-$uniqid = uniqid( '_' );
30
+$uniqid = uniqid('_');
31 31
 
32
-$address_type = empty( $address_type ) ? 'billing' : $address_type;
32
+$address_type = empty($address_type) ? 'billing' : $address_type;
33 33
 ?>
34 34
 
35
-<?php if ( 'both' === $address_type ) : ?>
35
+<?php if ('both' === $address_type) : ?>
36 36
 	<!-- Start Billing/Shipping Address Title -->
37 37
 	<h4 class="mb-3 getpaid-shipping-billing-address-title">
38
-		<?php esc_html_e( 'Billing / Shipping Address', 'invoicing' ); ?>
38
+		<?php esc_html_e('Billing / Shipping Address', 'invoicing'); ?>
39 39
 	</h4>
40 40
 	<!-- End Billing Address Title -->
41 41
 
42 42
 	<!-- Start Billing Address Title -->
43 43
 	<h4 class="mb-3 getpaid-billing-address-title">
44
-		<?php esc_html_e( 'Billing Address', 'invoicing' ); ?>
44
+		<?php esc_html_e('Billing Address', 'invoicing'); ?>
45 45
 	</h4>
46 46
 	<!-- End Billing Address Title -->
47 47
 <?php endif; ?>
48 48
 
49
-<?php if ( 'both' === $address_type || 'billing' === $address_type ) : ?>
49
+<?php if ('both' === $address_type || 'billing' === $address_type) : ?>
50 50
 	<!-- Start Billing Address -->
51 51
 	<div class="getpaid-billing-address-wrapper">
52 52
 		<?php
53 53
 			$field_type = 'billing';
54 54
 
55
-			wpinv_get_template( 'payment-forms/elements/address-fields.php', array( 'form' => $form, 'fields' => $fields, 'address_type' => $address_type, 'field_type' => $field_type, 'uniqid' => $uniqid, 'country' => $country ) );
55
+			wpinv_get_template('payment-forms/elements/address-fields.php', array('form' => $form, 'fields' => $fields, 'address_type' => $address_type, 'field_type' => $field_type, 'uniqid' => $uniqid, 'country' => $country));
56 56
 
57
-			do_action( 'getpaid_after_payment_form_billing_fields', $form );
57
+			do_action('getpaid_after_payment_form_billing_fields', $form);
58 58
 		?>
59 59
 	</div>
60 60
 	<!-- End Billing Address -->
61 61
 <?php endif; ?>
62 62
 
63
-<?php if ( 'both' === $address_type ) : ?>
63
+<?php if ('both' === $address_type) : ?>
64 64
 	<?php
65 65
 		aui()->input(
66 66
 			array(
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 				'name'     => 'same-shipping-address',
69 69
 				'id'       => "shipping-toggle$uniqid",
70 70
 				'required' => false,
71
-				'label'    => empty( $shipping_address_toggle ) ? esc_html__( 'Same billing & shipping address.', 'invoicing' ) : wp_kses_post( $shipping_address_toggle ),
71
+				'label'    => empty($shipping_address_toggle) ? esc_html__('Same billing & shipping address.', 'invoicing') : wp_kses_post($shipping_address_toggle),
72 72
 				'value'    => 1,
73 73
 				'checked'  => true,
74 74
 				'class'    => 'chkbox-same-shipping-address'
@@ -78,20 +78,20 @@  discard block
 block discarded – undo
78 78
 	?>
79 79
 	<!-- Start Shipping Address Title -->
80 80
 	<h4 class="mb-3 getpaid-shipping-address-title">
81
-		<?php esc_html_e( 'Shipping Address', 'invoicing' ); ?>
81
+		<?php esc_html_e('Shipping Address', 'invoicing'); ?>
82 82
 	</h4>
83 83
 	<!-- End Shipping Address Title -->
84 84
 <?php endif; ?>
85 85
 
86
-<?php if ( 'both' === $address_type || 'shipping' === $address_type ) : ?>
86
+<?php if ('both' === $address_type || 'shipping' === $address_type) : ?>
87 87
 	<!-- Start Shipping Address -->
88 88
 	<div class="getpaid-shipping-address-wrapper">
89 89
 		<?php
90 90
 			$field_type = 'shipping';
91 91
 
92
-			wpinv_get_template( 'payment-forms/elements/address-fields.php', array( 'form' => $form, 'fields' => $fields, 'address_type' => $address_type, 'field_type' => $field_type, 'uniqid' => $uniqid, 'country' => $country ) );
92
+			wpinv_get_template('payment-forms/elements/address-fields.php', array('form' => $form, 'fields' => $fields, 'address_type' => $address_type, 'field_type' => $field_type, 'uniqid' => $uniqid, 'country' => $country));
93 93
 
94
-			do_action( 'getpaid_after_payment_form_shipping_fields', $form );
94
+			do_action('getpaid_after_payment_form_shipping_fields', $form);
95 95
 		?>
96 96
 	</div>
97 97
 	<!-- End Shipping Address -->
Please login to merge, or discard this patch.
includes/admin/class-getpaid-post-types-admin.php 2 patches
Indentation   +812 added lines, -812 removed lines patch added patch discarded remove patch
@@ -13,755 +13,755 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Post_Types_Admin {
14 14
 
15 15
     /**
16
-	 * Hook in methods.
17
-	 */
18
-	public static function init() {
19
-
20
-		// Init metaboxes.
21
-		GetPaid_Metaboxes::init();
22
-
23
-		// Filter the post updated messages.
24
-		add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
25
-
26
-		// Filter post actions.
27
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
29
-
30
-		// Invoice table columns.
31
-		add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
-		add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
-		add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
-		add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
35
-
36
-		// Items table columns.
37
-		add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
-		add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
-		add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
-		add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
-		add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
-		add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
43
-
44
-		// Payment forms columns.
45
-		add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
-		add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
48
-
49
-		// Discount table columns.
50
-		add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
-		add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
52
-
53
-		// Deleting posts.
54
-		add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
56
-
57
-		add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
58
-	}
59
-
60
-	/**
61
-	 * Post updated messages.
62
-	 */
63
-	public static function post_updated_messages( $messages ) {
64
-		global $post;
65
-
66
-		$messages['wpi_discount'] = array(
67
-			0  => '',
68
-			1  => __( 'Discount updated.', 'invoicing' ),
69
-			2  => __( 'Custom field updated.', 'invoicing' ),
70
-			3  => __( 'Custom field deleted.', 'invoicing' ),
71
-			4  => __( 'Discount updated.', 'invoicing' ),
72
-			5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
-			6  => __( 'Discount updated.', 'invoicing' ),
74
-			7  => __( 'Discount saved.', 'invoicing' ),
75
-			8  => __( 'Discount submitted.', 'invoicing' ),
76
-			9  => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
-			10 => __( 'Discount draft updated.', 'invoicing' ),
78
-		);
79
-
80
-		$messages['wpi_payment_form'] = array(
81
-			0  => '',
82
-			1  => __( 'Payment Form updated.', 'invoicing' ),
83
-			2  => __( 'Custom field updated.', 'invoicing' ),
84
-			3  => __( 'Custom field deleted.', 'invoicing' ),
85
-			4  => __( 'Payment Form updated.', 'invoicing' ),
86
-			5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
-			6  => __( 'Payment Form updated.', 'invoicing' ),
88
-			7  => __( 'Payment Form saved.', 'invoicing' ),
89
-			8  => __( 'Payment Form submitted.', 'invoicing' ),
90
-			9  => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
-			10 => __( 'Payment Form draft updated.', 'invoicing' ),
92
-		);
93
-
94
-		return $messages;
95
-
96
-	}
97
-
98
-	/**
99
-	 * Post row actions.
100
-	 */
101
-	public static function post_row_actions( $actions, $post ) {
102
-
103
-		$post = get_post( $post );
104
-
105
-		// We do not want to edit the default payment form.
106
-		if ( 'wpi_payment_form' == $post->post_type ) {
107
-
108
-			if ( wpinv_get_default_payment_form() === $post->ID ) {
109
-				unset( $actions['trash'] );
110
-				unset( $actions['inline hide-if-no-js'] );
111
-			}
112
-
113
-			$actions['duplicate'] = sprintf(
114
-				'<a href="%1$s">%2$s</a>',
115
-				esc_url(
116
-					wp_nonce_url(
117
-						add_query_arg(
118
-							array(
119
-								'getpaid-admin-action' => 'duplicate_form',
120
-								'form_id'              => $post->ID,
121
-							)
122
-						),
123
-						'getpaid-nonce',
124
-						'getpaid-nonce'
125
-					)
126
-				),
127
-				esc_html( __( 'Duplicate', 'invoicing' ) )
128
-			);
129
-
130
-			$actions['reset'] = sprintf(
131
-				'<a href="%1$s" style="color: #800">%2$s</a>',
132
-				esc_url(
133
-					wp_nonce_url(
134
-						add_query_arg(
135
-							array(
136
-								'getpaid-admin-action' => 'reset_form_stats',
137
-								'form_id'              => $post->ID,
138
-							)
139
-						),
140
-						'getpaid-nonce',
141
-						'getpaid-nonce'
142
-					)
143
-				),
144
-				esc_html( __( 'Reset Stats', 'invoicing' ) )
145
-			);
146
-		}
147
-
148
-		// Link to item payment form.
149
-		if ( 'wpi_item' == $post->post_type ) {
150
-			if ( getpaid_item_type_supports( get_post_meta( $post->ID, '_wpinv_type', true ), 'buy_now' ) ) {
151
-				$actions['buy'] = sprintf(
152
-					'<a href="%1$s">%2$s</a>',
153
-					esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
154
-					esc_html( __( 'Buy', 'invoicing' ) )
155
-				);
156
-			}
157
-		}
158
-
159
-		return $actions;
160
-	}
161
-
162
-	/**
16
+     * Hook in methods.
17
+     */
18
+    public static function init() {
19
+
20
+        // Init metaboxes.
21
+        GetPaid_Metaboxes::init();
22
+
23
+        // Filter the post updated messages.
24
+        add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
25
+
26
+        // Filter post actions.
27
+        add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
+        add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
29
+
30
+        // Invoice table columns.
31
+        add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
+        add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
+        add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
+        add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
35
+
36
+        // Items table columns.
37
+        add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
+        add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
+        add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
+        add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
+        add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
+        add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
43
+
44
+        // Payment forms columns.
45
+        add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
+        add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
+        add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
48
+
49
+        // Discount table columns.
50
+        add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
+        add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
52
+
53
+        // Deleting posts.
54
+        add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
+        add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
56
+
57
+        add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
58
+    }
59
+
60
+    /**
61
+     * Post updated messages.
62
+     */
63
+    public static function post_updated_messages( $messages ) {
64
+        global $post;
65
+
66
+        $messages['wpi_discount'] = array(
67
+            0  => '',
68
+            1  => __( 'Discount updated.', 'invoicing' ),
69
+            2  => __( 'Custom field updated.', 'invoicing' ),
70
+            3  => __( 'Custom field deleted.', 'invoicing' ),
71
+            4  => __( 'Discount updated.', 'invoicing' ),
72
+            5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
+            6  => __( 'Discount updated.', 'invoicing' ),
74
+            7  => __( 'Discount saved.', 'invoicing' ),
75
+            8  => __( 'Discount submitted.', 'invoicing' ),
76
+            9  => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
+            10 => __( 'Discount draft updated.', 'invoicing' ),
78
+        );
79
+
80
+        $messages['wpi_payment_form'] = array(
81
+            0  => '',
82
+            1  => __( 'Payment Form updated.', 'invoicing' ),
83
+            2  => __( 'Custom field updated.', 'invoicing' ),
84
+            3  => __( 'Custom field deleted.', 'invoicing' ),
85
+            4  => __( 'Payment Form updated.', 'invoicing' ),
86
+            5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
+            6  => __( 'Payment Form updated.', 'invoicing' ),
88
+            7  => __( 'Payment Form saved.', 'invoicing' ),
89
+            8  => __( 'Payment Form submitted.', 'invoicing' ),
90
+            9  => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
+            10 => __( 'Payment Form draft updated.', 'invoicing' ),
92
+        );
93
+
94
+        return $messages;
95
+
96
+    }
97
+
98
+    /**
99
+     * Post row actions.
100
+     */
101
+    public static function post_row_actions( $actions, $post ) {
102
+
103
+        $post = get_post( $post );
104
+
105
+        // We do not want to edit the default payment form.
106
+        if ( 'wpi_payment_form' == $post->post_type ) {
107
+
108
+            if ( wpinv_get_default_payment_form() === $post->ID ) {
109
+                unset( $actions['trash'] );
110
+                unset( $actions['inline hide-if-no-js'] );
111
+            }
112
+
113
+            $actions['duplicate'] = sprintf(
114
+                '<a href="%1$s">%2$s</a>',
115
+                esc_url(
116
+                    wp_nonce_url(
117
+                        add_query_arg(
118
+                            array(
119
+                                'getpaid-admin-action' => 'duplicate_form',
120
+                                'form_id'              => $post->ID,
121
+                            )
122
+                        ),
123
+                        'getpaid-nonce',
124
+                        'getpaid-nonce'
125
+                    )
126
+                ),
127
+                esc_html( __( 'Duplicate', 'invoicing' ) )
128
+            );
129
+
130
+            $actions['reset'] = sprintf(
131
+                '<a href="%1$s" style="color: #800">%2$s</a>',
132
+                esc_url(
133
+                    wp_nonce_url(
134
+                        add_query_arg(
135
+                            array(
136
+                                'getpaid-admin-action' => 'reset_form_stats',
137
+                                'form_id'              => $post->ID,
138
+                            )
139
+                        ),
140
+                        'getpaid-nonce',
141
+                        'getpaid-nonce'
142
+                    )
143
+                ),
144
+                esc_html( __( 'Reset Stats', 'invoicing' ) )
145
+            );
146
+        }
147
+
148
+        // Link to item payment form.
149
+        if ( 'wpi_item' == $post->post_type ) {
150
+            if ( getpaid_item_type_supports( get_post_meta( $post->ID, '_wpinv_type', true ), 'buy_now' ) ) {
151
+                $actions['buy'] = sprintf(
152
+                    '<a href="%1$s">%2$s</a>',
153
+                    esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
154
+                    esc_html( __( 'Buy', 'invoicing' ) )
155
+                );
156
+            }
157
+        }
158
+
159
+        return $actions;
160
+    }
161
+
162
+    /**
163 163
      * Remove bulk edit option from admin side quote listing
164 164
      *
165 165
      * @since    1.0.0
166 166
      * @param array $actions post actions
167
-	 * @param WP_Post $post
167
+     * @param WP_Post $post
168 168
      * @return array $actions actions without edit option
169 169
      */
170 170
     public static function filter_invoice_row_actions( $actions, $post ) {
171 171
 
172 172
         if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
173 173
 
174
-			$actions = array();
175
-			$invoice = new WPInv_Invoice( $post );
176
-
177
-			$actions['edit'] = sprintf(
178
-				'<a href="%1$s">%2$s</a>',
179
-				esc_url( get_edit_post_link( $invoice->get_id() ) ),
180
-				esc_html( __( 'Edit', 'invoicing' ) )
181
-			);
182
-
183
-			if ( ! $invoice->is_draft() ) {
184
-
185
-				$actions['view'] = sprintf(
186
-					'<a href="%1$s">%2$s</a>',
187
-					esc_url( $invoice->get_view_url() ),
188
-					sprintf(
189
-						// translators: %s is the invoice type
190
-						esc_html__( 'View %s', 'invoicing' ),
191
-						getpaid_get_post_type_label( $invoice->get_post_type(), false )
192
-					)
193
-				);
194
-
195
-				$actions['send'] = sprintf(
196
-					'<a href="%1$s">%2$s</a>',
197
-					esc_url(
198
-						wp_nonce_url(
199
-							add_query_arg(
200
-								array(
201
-									'getpaid-admin-action' => 'send_invoice',
202
-									'invoice_id'           => $invoice->get_id(),
203
-								)
204
-							),
205
-							'getpaid-nonce',
206
-							'getpaid-nonce'
207
-						)
208
-					),
209
-					esc_html( __( 'Send to Customer', 'invoicing' ) )
210
-				);
211
-
212
-			}
213
-
214
-			$actions['duplicate'] = sprintf(
215
-				'<a href="%1$s">%2$s</a>',
216
-				esc_url(
217
-					wp_nonce_url(
218
-						add_query_arg(
219
-							array(
220
-								'getpaid-admin-action' => 'duplicate_invoice',
221
-								'invoice_id'           => $post->ID,
222
-							)
223
-						),
224
-						'getpaid-nonce',
225
-						'getpaid-nonce'
226
-					)
227
-				),
228
-				esc_html( __( 'Duplicate', 'invoicing' ) )
229
-			);
174
+            $actions = array();
175
+            $invoice = new WPInv_Invoice( $post );
176
+
177
+            $actions['edit'] = sprintf(
178
+                '<a href="%1$s">%2$s</a>',
179
+                esc_url( get_edit_post_link( $invoice->get_id() ) ),
180
+                esc_html( __( 'Edit', 'invoicing' ) )
181
+            );
182
+
183
+            if ( ! $invoice->is_draft() ) {
184
+
185
+                $actions['view'] = sprintf(
186
+                    '<a href="%1$s">%2$s</a>',
187
+                    esc_url( $invoice->get_view_url() ),
188
+                    sprintf(
189
+                        // translators: %s is the invoice type
190
+                        esc_html__( 'View %s', 'invoicing' ),
191
+                        getpaid_get_post_type_label( $invoice->get_post_type(), false )
192
+                    )
193
+                );
194
+
195
+                $actions['send'] = sprintf(
196
+                    '<a href="%1$s">%2$s</a>',
197
+                    esc_url(
198
+                        wp_nonce_url(
199
+                            add_query_arg(
200
+                                array(
201
+                                    'getpaid-admin-action' => 'send_invoice',
202
+                                    'invoice_id'           => $invoice->get_id(),
203
+                                )
204
+                            ),
205
+                            'getpaid-nonce',
206
+                            'getpaid-nonce'
207
+                        )
208
+                    ),
209
+                    esc_html( __( 'Send to Customer', 'invoicing' ) )
210
+                );
211
+
212
+            }
213
+
214
+            $actions['duplicate'] = sprintf(
215
+                '<a href="%1$s">%2$s</a>',
216
+                esc_url(
217
+                    wp_nonce_url(
218
+                        add_query_arg(
219
+                            array(
220
+                                'getpaid-admin-action' => 'duplicate_invoice',
221
+                                'invoice_id'           => $post->ID,
222
+                            )
223
+                        ),
224
+                        'getpaid-nonce',
225
+                        'getpaid-nonce'
226
+                    )
227
+                ),
228
+                esc_html( __( 'Duplicate', 'invoicing' ) )
229
+            );
230 230
 
231 231
         }
232 232
 
233 233
         return $actions;
234
-	}
235
-
236
-	/**
237
-	 * Returns an array of invoice table columns.
238
-	 */
239
-	public static function invoice_columns( $columns ) {
240
-
241
-		$columns = array(
242
-			'cb'           => $columns['cb'],
243
-			'number'       => __( 'Invoice', 'invoicing' ),
244
-			'customer'     => __( 'Customer', 'invoicing' ),
245
-			'invoice_date' => __( 'Created', 'invoicing' ),
246
-			'payment_date' => __( 'Completed', 'invoicing' ),
247
-			'amount'       => __( 'Amount', 'invoicing' ),
248
-			'recurring'    => __( 'Recurring', 'invoicing' ),
249
-			'status'       => __( 'Status', 'invoicing' ),
250
-		);
251
-
252
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
253
-	}
254
-
255
-	/**
256
-	 * Displays invoice table columns.
257
-	 */
258
-	public static function display_invoice_columns( $column_name, $post_id ) {
259
-
260
-		$invoice = new WPInv_Invoice( $post_id );
261
-
262
-		switch ( $column_name ) {
263
-
264
-			case 'invoice_date':
265
-				$date_time = esc_attr( $invoice->get_created_date() );
266
-				$date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
267
-				echo wp_kses_post( "<span title='$date_time'>$date</span>" );
268
-				break;
269
-
270
-			case 'payment_date':
271
-				if ( $invoice->is_paid() || $invoice->is_refunded() ) {
272
-					$date_time = esc_attr( $invoice->get_completed_date() );
273
-					$date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
274
-					echo wp_kses_post( "<span title='$date_time'>$date</span>" );
275
-
276
-					if ( $_gateway = $invoice->get_gateway() ) {
277
-						$gateway_label = wpinv_get_gateway_admin_label( $_gateway );
278
-
279
-						if ( $transaction_url = $invoice->get_transaction_url() ) {
280
-							$gateway_label = '<a href="' . esc_url( $transaction_url ) . '" target="_blank" title="' . esc_attr__( 'Open transaction link', 'invoicing' ) . '">' . $gateway_label . '</a>';
281
-						}
282
-
283
-						$gateway = '<small class="meta bsui"><span class="fs-xs text-muted fst-normal">' . wp_sprintf( _x( 'Via %s', 'Paid via gateway', 'invoicing' ), $gateway_label ) . '</span></small>';
284
-					} else {
285
-						$gateway = '';
286
-					}
287
-
288
-					$gateway = apply_filters( 'getpaid_admin_invoices_list_table_gateway', $gateway, $invoice );
289
-
290
-					if ( $gateway ) {
291
-						echo wp_kses_post( $gateway ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
292
-					}
293
-				} else {
294
-					echo '&mdash;';
295
-				}
296
-
297
-				break;
298
-
299
-			case 'amount':
300
-				$amount = $invoice->get_total();
301
-				$formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) );
302
-
303
-				if ( $invoice->is_refunded() ) {
304
-					$refunded_amount = wpinv_price( 0, $invoice->get_currency() );
305
-					echo wp_kses_post( "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>" );
306
-				} else {
307
-
308
-					$discount = $invoice->get_total_discount();
309
-
310
-					if ( ! empty( $discount ) ) {
311
-						$new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
312
-						echo wp_kses_post( "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>" );
313
-					} else {
314
-						echo wp_kses_post( $formated_amount );
315
-					}
316
-				}
317
-
318
-				break;
319
-
320
-			case 'status':
321
-				$status = esc_html( $invoice->get_status() );
322
-
323
-				// If it is paid, show the gateway title.
324
-				if ( $invoice->is_paid() ) {
325
-					$gateway = esc_html( $invoice->get_gateway_title() );
326
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) );
327
-
328
-					echo wp_kses_post( "<span class='bsui wpi-help-tip getpaid-invoice-statuss $status' title='$gateway'><span class='fs-base'>" . $invoice->get_status_label_html() . "</span></span>" );
329
-				} else {
330
-					echo wp_kses_post( "<span class='bsui getpaid-invoice-statuss $status'><span class='fs-base'>" . $invoice->get_status_label_html() . "</span></span>" );
331
-				}
332
-
333
-				// If it is not paid, display the overdue and view status.
334
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
335
-
336
-					// Invoice view status.
337
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
338
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>';
339
-					} else {
340
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>';
341
-					}
342
-
343
-					// Display the overview status.
344
-					if ( wpinv_get_option( 'overdue_active' ) ) {
345
-						$due_date = $invoice->get_due_date();
346
-						$fomatted = getpaid_format_date( $due_date );
347
-
348
-						if ( ! empty( $fomatted ) ) {
349
-							$date = wp_sprintf(
350
-								// translators: %s is the due date.
351
-								__( 'Due %s', 'invoicing' ),
352
-								$fomatted
353
-							);
354
-							echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" );
355
-						}
356
-					}
357
-				}
358
-
359
-				break;
360
-
361
-			case 'recurring':
362
-				if ( $invoice->is_recurring() ) {
363
-					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
364
-				} else {
365
-					echo '<i class="fa fa-times" style="color:#616161;"></i>';
366
-				}
367
-				break;
368
-
369
-			case 'number':
370
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
371
-				$invoice_number  = esc_html( $invoice->get_number() );
372
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
373
-
374
-				echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" );
375
-
376
-				do_action( 'getpaid_admin_table_invoice_number_column', $invoice );
377
-				break;
378
-
379
-			case 'customer':
380
-				$customer_name = $invoice->get_user_full_name();
381
-
382
-				if ( empty( $customer_name ) ) {
383
-					$customer_name = $invoice->get_email();
384
-				}
385
-
386
-				if ( ! empty( $customer_name ) ) {
387
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
388
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
389
-					echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" );
390
-				} else {
391
-					echo '<div>&mdash;</div>';
392
-				}
393
-
394
-				break;
395
-
396
-		}
397
-
398
-	}
399
-
400
-	/**
401
-	 * Displays invoice bulk actions.
402
-	 */
403
-	public static function invoice_bulk_actions( $actions ) {
404
-		$actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
405
-		return $actions;
406
-	}
407
-
408
-	/**
409
-	 * Processes invoice bulk actions.
410
-	 */
411
-	public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
412
-
413
-		if ( 'resend-invoice' === $action ) {
414
-			foreach ( $post_ids as $post_id ) {
415
-				getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
416
-			}
417
-		}
418
-
419
-		return $redirect_url;
420
-
421
-	}
422
-
423
-	/**
424
-	 * Returns an array of payment forms table columns.
425
-	 */
426
-	public static function payment_form_columns( $columns ) {
427
-
428
-		$columns = array(
429
-			'cb'        => $columns['cb'],
430
-			'title'     => __( 'Name', 'invoicing' ),
431
-			'shortcode' => __( 'Shortcode', 'invoicing' ),
432
-			'earnings'  => __( 'Revenue', 'invoicing' ),
433
-			'refunds'   => __( 'Refunded', 'invoicing' ),
434
-			'items'     => __( 'Items', 'invoicing' ),
435
-			'date'      => __( 'Date', 'invoicing' ),
436
-		);
437
-
438
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
439
-
440
-	}
441
-
442
-	/**
443
-	 * Displays payment form table columns.
444
-	 */
445
-	public static function display_payment_form_columns( $column_name, $post_id ) {
446
-
447
-		// Retrieve the payment form.
448
-		$form = new GetPaid_Payment_Form( $post_id );
449
-
450
-		switch ( $column_name ) {
451
-
452
-			case 'earnings':
453
-				echo wp_kses_post( wpinv_price( $form->get_earned() ) );
454
-				break;
455
-
456
-			case 'refunds':
457
-				echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
458
-				break;
459
-
460
-			case 'refunds':
461
-				echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
462
-				break;
463
-
464
-			case 'shortcode':
465
-				if ( $form->is_default() ) {
466
-					echo '&mdash;';
467
-				} else {
468
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
469
-				}
470
-
471
-				break;
234
+    }
235
+
236
+    /**
237
+     * Returns an array of invoice table columns.
238
+     */
239
+    public static function invoice_columns( $columns ) {
240
+
241
+        $columns = array(
242
+            'cb'           => $columns['cb'],
243
+            'number'       => __( 'Invoice', 'invoicing' ),
244
+            'customer'     => __( 'Customer', 'invoicing' ),
245
+            'invoice_date' => __( 'Created', 'invoicing' ),
246
+            'payment_date' => __( 'Completed', 'invoicing' ),
247
+            'amount'       => __( 'Amount', 'invoicing' ),
248
+            'recurring'    => __( 'Recurring', 'invoicing' ),
249
+            'status'       => __( 'Status', 'invoicing' ),
250
+        );
251
+
252
+        return apply_filters( 'wpi_invoice_table_columns', $columns );
253
+    }
254
+
255
+    /**
256
+     * Displays invoice table columns.
257
+     */
258
+    public static function display_invoice_columns( $column_name, $post_id ) {
259
+
260
+        $invoice = new WPInv_Invoice( $post_id );
261
+
262
+        switch ( $column_name ) {
263
+
264
+            case 'invoice_date':
265
+                $date_time = esc_attr( $invoice->get_created_date() );
266
+                $date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
267
+                echo wp_kses_post( "<span title='$date_time'>$date</span>" );
268
+                break;
269
+
270
+            case 'payment_date':
271
+                if ( $invoice->is_paid() || $invoice->is_refunded() ) {
272
+                    $date_time = esc_attr( $invoice->get_completed_date() );
273
+                    $date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
274
+                    echo wp_kses_post( "<span title='$date_time'>$date</span>" );
275
+
276
+                    if ( $_gateway = $invoice->get_gateway() ) {
277
+                        $gateway_label = wpinv_get_gateway_admin_label( $_gateway );
278
+
279
+                        if ( $transaction_url = $invoice->get_transaction_url() ) {
280
+                            $gateway_label = '<a href="' . esc_url( $transaction_url ) . '" target="_blank" title="' . esc_attr__( 'Open transaction link', 'invoicing' ) . '">' . $gateway_label . '</a>';
281
+                        }
282
+
283
+                        $gateway = '<small class="meta bsui"><span class="fs-xs text-muted fst-normal">' . wp_sprintf( _x( 'Via %s', 'Paid via gateway', 'invoicing' ), $gateway_label ) . '</span></small>';
284
+                    } else {
285
+                        $gateway = '';
286
+                    }
287
+
288
+                    $gateway = apply_filters( 'getpaid_admin_invoices_list_table_gateway', $gateway, $invoice );
289
+
290
+                    if ( $gateway ) {
291
+                        echo wp_kses_post( $gateway ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
292
+                    }
293
+                } else {
294
+                    echo '&mdash;';
295
+                }
296
+
297
+                break;
298
+
299
+            case 'amount':
300
+                $amount = $invoice->get_total();
301
+                $formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) );
302
+
303
+                if ( $invoice->is_refunded() ) {
304
+                    $refunded_amount = wpinv_price( 0, $invoice->get_currency() );
305
+                    echo wp_kses_post( "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>" );
306
+                } else {
307
+
308
+                    $discount = $invoice->get_total_discount();
309
+
310
+                    if ( ! empty( $discount ) ) {
311
+                        $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
312
+                        echo wp_kses_post( "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>" );
313
+                    } else {
314
+                        echo wp_kses_post( $formated_amount );
315
+                    }
316
+                }
317
+
318
+                break;
319
+
320
+            case 'status':
321
+                $status = esc_html( $invoice->get_status() );
322
+
323
+                // If it is paid, show the gateway title.
324
+                if ( $invoice->is_paid() ) {
325
+                    $gateway = esc_html( $invoice->get_gateway_title() );
326
+                    $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) );
327
+
328
+                    echo wp_kses_post( "<span class='bsui wpi-help-tip getpaid-invoice-statuss $status' title='$gateway'><span class='fs-base'>" . $invoice->get_status_label_html() . "</span></span>" );
329
+                } else {
330
+                    echo wp_kses_post( "<span class='bsui getpaid-invoice-statuss $status'><span class='fs-base'>" . $invoice->get_status_label_html() . "</span></span>" );
331
+                }
332
+
333
+                // If it is not paid, display the overdue and view status.
334
+                if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
335
+
336
+                    // Invoice view status.
337
+                    if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
338
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>';
339
+                    } else {
340
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>';
341
+                    }
342
+
343
+                    // Display the overview status.
344
+                    if ( wpinv_get_option( 'overdue_active' ) ) {
345
+                        $due_date = $invoice->get_due_date();
346
+                        $fomatted = getpaid_format_date( $due_date );
347
+
348
+                        if ( ! empty( $fomatted ) ) {
349
+                            $date = wp_sprintf(
350
+                                // translators: %s is the due date.
351
+                                __( 'Due %s', 'invoicing' ),
352
+                                $fomatted
353
+                            );
354
+                            echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" );
355
+                        }
356
+                    }
357
+                }
358
+
359
+                break;
360
+
361
+            case 'recurring':
362
+                if ( $invoice->is_recurring() ) {
363
+                    echo '<i class="fa fa-check" style="color:#43850a;"></i>';
364
+                } else {
365
+                    echo '<i class="fa fa-times" style="color:#616161;"></i>';
366
+                }
367
+                break;
368
+
369
+            case 'number':
370
+                $edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
371
+                $invoice_number  = esc_html( $invoice->get_number() );
372
+                $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
373
+
374
+                echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" );
375
+
376
+                do_action( 'getpaid_admin_table_invoice_number_column', $invoice );
377
+                break;
378
+
379
+            case 'customer':
380
+                $customer_name = $invoice->get_user_full_name();
381
+
382
+                if ( empty( $customer_name ) ) {
383
+                    $customer_name = $invoice->get_email();
384
+                }
385
+
386
+                if ( ! empty( $customer_name ) ) {
387
+                    $customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
388
+                    $view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
389
+                    echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" );
390
+                } else {
391
+                    echo '<div>&mdash;</div>';
392
+                }
393
+
394
+                break;
472 395
 
473
-			case 'items':
474
-				$items = $form->get_items();
475
-
476
-				if ( $form->is_default() || empty( $items ) ) {
477
-					echo '&mdash;';
478
-					return;
479
-				}
480
-
481
-				$_items = array();
482
-
483
-				foreach ( $items as $item ) {
484
-					$url = $item->get_edit_url();
485
-
486
-					if ( empty( $url ) ) {
487
-						$_items[] = esc_html( $item->get_name() );
488
-					} else {
489
-						$_items[] = sprintf(
490
-							'<a href="%s">%s</a>',
491
-							esc_url( $url ),
492
-							esc_html( $item->get_name() )
493
-						);
494
-					}
396
+        }
397
+
398
+    }
399
+
400
+    /**
401
+     * Displays invoice bulk actions.
402
+     */
403
+    public static function invoice_bulk_actions( $actions ) {
404
+        $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
405
+        return $actions;
406
+    }
407
+
408
+    /**
409
+     * Processes invoice bulk actions.
410
+     */
411
+    public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
412
+
413
+        if ( 'resend-invoice' === $action ) {
414
+            foreach ( $post_ids as $post_id ) {
415
+                getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
416
+            }
417
+        }
418
+
419
+        return $redirect_url;
420
+
421
+    }
422
+
423
+    /**
424
+     * Returns an array of payment forms table columns.
425
+     */
426
+    public static function payment_form_columns( $columns ) {
427
+
428
+        $columns = array(
429
+            'cb'        => $columns['cb'],
430
+            'title'     => __( 'Name', 'invoicing' ),
431
+            'shortcode' => __( 'Shortcode', 'invoicing' ),
432
+            'earnings'  => __( 'Revenue', 'invoicing' ),
433
+            'refunds'   => __( 'Refunded', 'invoicing' ),
434
+            'items'     => __( 'Items', 'invoicing' ),
435
+            'date'      => __( 'Date', 'invoicing' ),
436
+        );
437
+
438
+        return apply_filters( 'wpi_payment_form_table_columns', $columns );
439
+
440
+    }
441
+
442
+    /**
443
+     * Displays payment form table columns.
444
+     */
445
+    public static function display_payment_form_columns( $column_name, $post_id ) {
446
+
447
+        // Retrieve the payment form.
448
+        $form = new GetPaid_Payment_Form( $post_id );
449
+
450
+        switch ( $column_name ) {
451
+
452
+            case 'earnings':
453
+                echo wp_kses_post( wpinv_price( $form->get_earned() ) );
454
+                break;
455
+
456
+            case 'refunds':
457
+                echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
458
+                break;
459
+
460
+            case 'refunds':
461
+                echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
462
+                break;
463
+
464
+            case 'shortcode':
465
+                if ( $form->is_default() ) {
466
+                    echo '&mdash;';
467
+                } else {
468
+                    echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
469
+                }
470
+
471
+                break;
472
+
473
+            case 'items':
474
+                $items = $form->get_items();
475
+
476
+                if ( $form->is_default() || empty( $items ) ) {
477
+                    echo '&mdash;';
478
+                    return;
479
+                }
480
+
481
+                $_items = array();
482
+
483
+                foreach ( $items as $item ) {
484
+                    $url = $item->get_edit_url();
485
+
486
+                    if ( empty( $url ) ) {
487
+                        $_items[] = esc_html( $item->get_name() );
488
+                    } else {
489
+                        $_items[] = sprintf(
490
+                            '<a href="%s">%s</a>',
491
+                            esc_url( $url ),
492
+                            esc_html( $item->get_name() )
493
+                        );
494
+                    }
495 495
 }
496 496
 
497
-				echo wp_kses_post( implode( '<br>', $_items ) );
497
+                echo wp_kses_post( implode( '<br>', $_items ) );
498
+
499
+                break;
500
+
501
+        }
502
+
503
+    }
504
+
505
+    /**
506
+     * Filters post states.
507
+     */
508
+    public static function filter_payment_form_state( $post_states, $post ) {
509
+
510
+        if ( 'wpi_payment_form' === $post->post_type && wpinv_get_default_payment_form() === $post->ID ) {
511
+            $post_states['default_form'] = __( 'Default Payment Form', 'invoicing' );
512
+        }
513
+
514
+        return $post_states;
515
+
516
+    }
517
+
518
+    /**
519
+     * Returns an array of coupon table columns.
520
+     */
521
+    public static function discount_columns( $columns ) {
522
+
523
+        $columns = array(
524
+            'cb'          => $columns['cb'],
525
+            'title'       => __( 'Name', 'invoicing' ),
526
+            'code'        => __( 'Code', 'invoicing' ),
527
+            'amount'      => __( 'Amount', 'invoicing' ),
528
+            'usage'       => __( 'Usage / Limit', 'invoicing' ),
529
+            'start_date'  => __( 'Start Date', 'invoicing' ),
530
+            'expiry_date' => __( 'Expiry Date', 'invoicing' ),
531
+        );
532
+
533
+        return apply_filters( 'wpi_discount_table_columns', $columns );
534
+    }
498 535
 
499
-				break;
536
+    /**
537
+     * Filters post states.
538
+     */
539
+    public static function filter_discount_state( $post_states, $post ) {
500 540
 
501
-		}
541
+        if ( 'wpi_discount' === $post->post_type ) {
502 542
 
503
-	}
543
+            $discount = new WPInv_Discount( $post );
504 544
 
505
-	/**
506
-	 * Filters post states.
507
-	 */
508
-	public static function filter_payment_form_state( $post_states, $post ) {
545
+            $status = $discount->is_expired() ? 'expired' : $discount->get_status();
509 546
 
510
-		if ( 'wpi_payment_form' === $post->post_type && wpinv_get_default_payment_form() === $post->ID ) {
511
-			$post_states['default_form'] = __( 'Default Payment Form', 'invoicing' );
512
-		}
547
+            if ( 'publish' !== $status ) {
548
+                return array(
549
+                    'discount_status' => wpinv_discount_status( $status ),
550
+                );
551
+            }
552
+
553
+            return array();
554
+
555
+        }
556
+
557
+        return $post_states;
513 558
 
514
-		return $post_states;
559
+    }
515 560
 
516
-	}
561
+    /**
562
+     * Returns an array of items table columns.
563
+     */
564
+    public static function item_columns( $columns ) {
565
+
566
+        $columns = array(
567
+            'cb'        => $columns['cb'],
568
+            'title'     => __( 'Name', 'invoicing' ),
569
+            'price'     => __( 'Price', 'invoicing' ),
570
+            'vat_rule'  => __( 'Tax Rule', 'invoicing' ),
571
+            'vat_class' => __( 'Tax Class', 'invoicing' ),
572
+            'type'      => __( 'Type', 'invoicing' ),
573
+            'shortcode' => __( 'Shortcode', 'invoicing' ),
574
+        );
575
+
576
+        if ( ! wpinv_use_taxes() ) {
577
+            unset( $columns['vat_rule'] );
578
+            unset( $columns['vat_class'] );
579
+        }
517 580
 
518
-	/**
519
-	 * Returns an array of coupon table columns.
520
-	 */
521
-	public static function discount_columns( $columns ) {
581
+        return apply_filters( 'wpi_item_table_columns', $columns );
582
+    }
522 583
 
523
-		$columns = array(
524
-			'cb'          => $columns['cb'],
525
-			'title'       => __( 'Name', 'invoicing' ),
526
-			'code'        => __( 'Code', 'invoicing' ),
527
-			'amount'      => __( 'Amount', 'invoicing' ),
528
-			'usage'       => __( 'Usage / Limit', 'invoicing' ),
529
-			'start_date'  => __( 'Start Date', 'invoicing' ),
530
-			'expiry_date' => __( 'Expiry Date', 'invoicing' ),
531
-		);
584
+    /**
585
+     * Returns an array of sortable items table columns.
586
+     */
587
+    public static function sortable_item_columns( $columns ) {
588
+
589
+        return array_merge(
590
+            $columns,
591
+            array(
592
+                'price'     => 'price',
593
+                'vat_rule'  => 'vat_rule',
594
+                'vat_class' => 'vat_class',
595
+                'type'      => 'type',
596
+            )
597
+        );
532 598
 
533
-		return apply_filters( 'wpi_discount_table_columns', $columns );
534
-	}
599
+    }
535 600
 
536
-	/**
537
-	 * Filters post states.
538
-	 */
539
-	public static function filter_discount_state( $post_states, $post ) {
601
+    /**
602
+     * Displays items table columns.
603
+     */
604
+    public static function display_item_columns( $column_name, $post_id ) {
540 605
 
541
-		if ( 'wpi_discount' === $post->post_type ) {
606
+        $item = new WPInv_Item( $post_id );
542 607
 
543
-			$discount = new WPInv_Discount( $post );
608
+        switch ( $column_name ) {
544 609
 
545
-			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
610
+            case 'price':
611
+                if ( ! $item->is_recurring() ) {
612
+                    echo wp_kses_post( $item->get_the_price() );
613
+                    break;
614
+                }
546 615
 
547
-			if ( 'publish' !== $status ) {
548
-				return array(
549
-					'discount_status' => wpinv_discount_status( $status ),
550
-				);
551
-			}
616
+                $price = wp_sprintf(
617
+                    __( '%1$s / %2$s', 'invoicing' ),
618
+                    $item->get_the_price(),
619
+                    getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
620
+                );
552 621
 
553
-			return array();
622
+                if ( $item->get_the_price() == $item->get_the_initial_price() ) {
623
+                    echo wp_kses_post( $price );
624
+                    break;
625
+                }
554 626
 
555
-		}
627
+                echo wp_kses_post( $item->get_the_initial_price() );
556 628
 
557
-		return $post_states;
629
+                echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>';
630
+                break;
558 631
 
559
-	}
632
+            case 'vat_rule':
633
+                echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) );
634
+                break;
560 635
 
561
-	/**
562
-	 * Returns an array of items table columns.
563
-	 */
564
-	public static function item_columns( $columns ) {
636
+            case 'vat_class':
637
+                echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) );
638
+                break;
565 639
 
566
-		$columns = array(
567
-			'cb'        => $columns['cb'],
568
-			'title'     => __( 'Name', 'invoicing' ),
569
-			'price'     => __( 'Price', 'invoicing' ),
570
-			'vat_rule'  => __( 'Tax Rule', 'invoicing' ),
571
-			'vat_class' => __( 'Tax Class', 'invoicing' ),
572
-			'type'      => __( 'Type', 'invoicing' ),
573
-			'shortcode' => __( 'Shortcode', 'invoicing' ),
574
-		);
640
+            case 'shortcode':
641
+                if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
642
+                    echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
643
+                } else {
644
+                    echo '&mdash;';
645
+                }
575 646
 
576
-		if ( ! wpinv_use_taxes() ) {
577
-			unset( $columns['vat_rule'] );
578
-			unset( $columns['vat_class'] );
579
-		}
647
+                break;
580 648
 
581
-		return apply_filters( 'wpi_item_table_columns', $columns );
582
-	}
649
+            case 'type':
650
+                echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' );
651
+                break;
583 652
 
584
-	/**
585
-	 * Returns an array of sortable items table columns.
586
-	 */
587
-	public static function sortable_item_columns( $columns ) {
588
-
589
-		return array_merge(
590
-			$columns,
591
-			array(
592
-				'price'     => 'price',
593
-				'vat_rule'  => 'vat_rule',
594
-				'vat_class' => 'vat_class',
595
-				'type'      => 'type',
596
-			)
597
-		);
598
-
599
-	}
600
-
601
-	/**
602
-	 * Displays items table columns.
603
-	 */
604
-	public static function display_item_columns( $column_name, $post_id ) {
605
-
606
-		$item = new WPInv_Item( $post_id );
607
-
608
-		switch ( $column_name ) {
609
-
610
-			case 'price':
611
-				if ( ! $item->is_recurring() ) {
612
-					echo wp_kses_post( $item->get_the_price() );
613
-					break;
614
-				}
615
-
616
-				$price = wp_sprintf(
617
-					__( '%1$s / %2$s', 'invoicing' ),
618
-					$item->get_the_price(),
619
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
620
-				);
621
-
622
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
623
-					echo wp_kses_post( $price );
624
-					break;
625
-				}
626
-
627
-				echo wp_kses_post( $item->get_the_initial_price() );
628
-
629
-				echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>';
630
-				break;
631
-
632
-			case 'vat_rule':
633
-				echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) );
634
-				break;
635
-
636
-			case 'vat_class':
637
-				echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) );
638
-				break;
639
-
640
-			case 'shortcode':
641
-				if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
642
-					echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
643
-				} else {
644
-					echo '&mdash;';
645
-				}
646
-
647
-				break;
648
-
649
-			case 'type':
650
-				echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' );
651
-				break;
652
-
653
-		}
654
-
655
-	}
656
-
657
-	/**
658
-	 * Lets users filter items using taxes.
659
-	 */
660
-	public static function add_item_filters( $post_type ) {
661
-
662
-		// Abort if we're not dealing with items.
663
-		if ( 'wpi_item' !== $post_type ) {
664
-			return;
665
-		}
666
-
667
-		// Filter by vat rules.
668
-		if ( wpinv_use_taxes() ) {
669
-
670
-			// Sanitize selected vat rule.
671
-			$vat_rule   = '';
672
-			$vat_rules  = getpaid_get_tax_rules();
673
-			if ( isset( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
674
-				$vat_rule   = sanitize_text_field( $_GET['vat_rule'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
675
-			}
676
-
677
-			// Filter by VAT rule.
678
-			wpinv_html_select(
679
-				array(
680
-					'options'          => array_merge(
681
-						array(
682
-							'' => __( 'All Tax Rules', 'invoicing' ),
683
-						),
684
-						$vat_rules
685
-					),
686
-					'name'             => 'vat_rule',
687
-					'id'               => 'vat_rule',
688
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ), true ) ? $vat_rule : '',
689
-					'show_option_all'  => false,
690
-					'show_option_none' => false,
691
-				)
692
-			);
693
-
694
-			// Filter by VAT class.
695
-
696
-			// Sanitize selected vat rule.
697
-			$vat_class   = '';
698
-			$vat_classes = getpaid_get_tax_classes();
699
-			if ( isset( $_GET['vat_class'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
700
-				$vat_class   = sanitize_text_field( $_GET['vat_class'] );  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
701
-			}
702
-
703
-			wpinv_html_select(
704
-				array(
705
-					'options'          => array_merge(
706
-						array(
707
-							'' => __( 'All Tax Classes', 'invoicing' ),
708
-						),
709
-						$vat_classes
710
-					),
711
-					'name'             => 'vat_class',
712
-					'id'               => 'vat_class',
713
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ), true ) ? $vat_class : '',
714
-					'show_option_all'  => false,
715
-					'show_option_none' => false,
716
-				)
717
-			);
718
-
719
-		}
720
-
721
-		// Filter by item type.
722
-		$type   = '';
723
-		if ( isset( $_GET['type'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
724
-			$type   = sanitize_text_field( $_GET['type'] );  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
725
-		}
726
-
727
-		wpinv_html_select(
728
-			array(
729
-				'options'          => array_merge(
730
-					array(
731
-						'' => __( 'All item types', 'invoicing' ),
732
-					),
733
-					wpinv_get_item_types()
734
-				),
735
-				'name'             => 'type',
736
-				'id'               => 'type',
737
-				'selected'         => in_array( $type, wpinv_item_types(), true ) ? $type : '',
738
-				'show_option_all'  => false,
739
-				'show_option_none' => false,
740
-			)
741
-		);
742
-
743
-	}
744
-
745
-	/**
746
-	 * Filters the item query.
747
-	 */
748
-	public static function filter_item_query( $query ) {
749
-
750
-		// modify the query only if it admin and main query.
751
-		if ( ! ( is_admin() && $query->is_main_query() ) ) {
752
-			return $query;
753
-		}
754
-
755
-		// we want to modify the query for our items.
756
-		if ( empty( $query->query['post_type'] ) || 'wpi_item' !== $query->query['post_type'] ) {
757
-			return $query;
758
-		}
759
-
760
-		if ( empty( $query->query_vars['meta_query'] ) ) {
761
-			$query->query_vars['meta_query'] = array();
762
-		}
763
-
764
-		// Filter vat rule type
653
+        }
654
+
655
+    }
656
+
657
+    /**
658
+     * Lets users filter items using taxes.
659
+     */
660
+    public static function add_item_filters( $post_type ) {
661
+
662
+        // Abort if we're not dealing with items.
663
+        if ( 'wpi_item' !== $post_type ) {
664
+            return;
665
+        }
666
+
667
+        // Filter by vat rules.
668
+        if ( wpinv_use_taxes() ) {
669
+
670
+            // Sanitize selected vat rule.
671
+            $vat_rule   = '';
672
+            $vat_rules  = getpaid_get_tax_rules();
673
+            if ( isset( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
674
+                $vat_rule   = sanitize_text_field( $_GET['vat_rule'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
675
+            }
676
+
677
+            // Filter by VAT rule.
678
+            wpinv_html_select(
679
+                array(
680
+                    'options'          => array_merge(
681
+                        array(
682
+                            '' => __( 'All Tax Rules', 'invoicing' ),
683
+                        ),
684
+                        $vat_rules
685
+                    ),
686
+                    'name'             => 'vat_rule',
687
+                    'id'               => 'vat_rule',
688
+                    'selected'         => in_array( $vat_rule, array_keys( $vat_rules ), true ) ? $vat_rule : '',
689
+                    'show_option_all'  => false,
690
+                    'show_option_none' => false,
691
+                )
692
+            );
693
+
694
+            // Filter by VAT class.
695
+
696
+            // Sanitize selected vat rule.
697
+            $vat_class   = '';
698
+            $vat_classes = getpaid_get_tax_classes();
699
+            if ( isset( $_GET['vat_class'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
700
+                $vat_class   = sanitize_text_field( $_GET['vat_class'] );  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
701
+            }
702
+
703
+            wpinv_html_select(
704
+                array(
705
+                    'options'          => array_merge(
706
+                        array(
707
+                            '' => __( 'All Tax Classes', 'invoicing' ),
708
+                        ),
709
+                        $vat_classes
710
+                    ),
711
+                    'name'             => 'vat_class',
712
+                    'id'               => 'vat_class',
713
+                    'selected'         => in_array( $vat_class, array_keys( $vat_classes ), true ) ? $vat_class : '',
714
+                    'show_option_all'  => false,
715
+                    'show_option_none' => false,
716
+                )
717
+            );
718
+
719
+        }
720
+
721
+        // Filter by item type.
722
+        $type   = '';
723
+        if ( isset( $_GET['type'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
724
+            $type   = sanitize_text_field( $_GET['type'] );  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
725
+        }
726
+
727
+        wpinv_html_select(
728
+            array(
729
+                'options'          => array_merge(
730
+                    array(
731
+                        '' => __( 'All item types', 'invoicing' ),
732
+                    ),
733
+                    wpinv_get_item_types()
734
+                ),
735
+                'name'             => 'type',
736
+                'id'               => 'type',
737
+                'selected'         => in_array( $type, wpinv_item_types(), true ) ? $type : '',
738
+                'show_option_all'  => false,
739
+                'show_option_none' => false,
740
+            )
741
+        );
742
+
743
+    }
744
+
745
+    /**
746
+     * Filters the item query.
747
+     */
748
+    public static function filter_item_query( $query ) {
749
+
750
+        // modify the query only if it admin and main query.
751
+        if ( ! ( is_admin() && $query->is_main_query() ) ) {
752
+            return $query;
753
+        }
754
+
755
+        // we want to modify the query for our items.
756
+        if ( empty( $query->query['post_type'] ) || 'wpi_item' !== $query->query['post_type'] ) {
757
+            return $query;
758
+        }
759
+
760
+        if ( empty( $query->query_vars['meta_query'] ) ) {
761
+            $query->query_vars['meta_query'] = array();
762
+        }
763
+
764
+        // Filter vat rule type
765 765
         if ( ! empty( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
766 766
             $query->query_vars['meta_query'][] = array(
767 767
                 'key'     => '_wpinv_vat_rule',
@@ -786,101 +786,101 @@  discard block
 block discarded – undo
786 786
                 'value'   => sanitize_text_field( $_GET['type'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended
787 787
                 'compare' => '=',
788 788
             );
789
-		}
790
-
791
-		$query->query_vars['meta_query'][] = array(
792
-			'key'     => '_wpinv_one_time',
793
-			'compare' => 'NOT EXISTS',
794
-		);
795
-	}
796
-
797
-	/**
798
-	 * Reorders items.
799
-	 */
800
-	public static function reorder_items( $vars ) {
801
-		global $typenow;
802
-
803
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
804
-			return $vars;
805
-		}
806
-
807
-		// By item type.
808
-		if ( 'type' === $vars['orderby'] ) {
809
-			return array_merge(
810
-				$vars,
811
-				array(
812
-					'meta_key' => '_wpinv_type',
813
-					'orderby'  => 'meta_value',
814
-				)
815
-			);
816
-		}
817
-
818
-		// By vat class.
819
-		if ( 'vat_class' === $vars['orderby'] ) {
820
-			return array_merge(
821
-				$vars,
822
-				array(
823
-					'meta_key' => '_wpinv_vat_class',
824
-					'orderby'  => 'meta_value',
825
-				)
826
-			);
827
-		}
828
-
829
-		// By vat rule.
830
-		if ( 'vat_rule' === $vars['orderby'] ) {
831
-			return array_merge(
832
-				$vars,
833
-				array(
834
-					'meta_key' => '_wpinv_vat_rule',
835
-					'orderby'  => 'meta_value',
836
-				)
837
-			);
838
-		}
839
-
840
-		// By price.
841
-		if ( 'price' === $vars['orderby'] ) {
842
-			return array_merge(
843
-				$vars,
844
-				array(
845
-					'meta_key' => '_wpinv_price',
846
-					'orderby'  => 'meta_value_num',
847
-				)
848
-			);
849
-		}
850
-
851
-		return $vars;
852
-
853
-	}
854
-
855
-	/**
856
-	 * Fired when deleting a post.
857
-	 */
858
-	public static function delete_post( $post_id ) {
859
-
860
-		switch ( get_post_type( $post_id ) ) {
861
-
862
-			case 'wpi_item':
863
-				do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) );
864
-				break;
865
-
866
-			case 'wpi_payment_form':
867
-				do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) );
868
-				break;
869
-
870
-			case 'wpi_discount':
871
-				do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) );
872
-				break;
873
-
874
-			case 'wpi_invoice':
875
-				$invoice = new WPInv_Invoice( $post_id );
876
-				do_action( 'getpaid_before_delete_invoice', $invoice );
877
-				$invoice->get_data_store()->delete_items( $invoice );
878
-				$invoice->get_data_store()->delete_special_fields( $invoice );
879
-				break;
880
-		}
881
-	}
882
-
883
-	/**
789
+        }
790
+
791
+        $query->query_vars['meta_query'][] = array(
792
+            'key'     => '_wpinv_one_time',
793
+            'compare' => 'NOT EXISTS',
794
+        );
795
+    }
796
+
797
+    /**
798
+     * Reorders items.
799
+     */
800
+    public static function reorder_items( $vars ) {
801
+        global $typenow;
802
+
803
+        if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
804
+            return $vars;
805
+        }
806
+
807
+        // By item type.
808
+        if ( 'type' === $vars['orderby'] ) {
809
+            return array_merge(
810
+                $vars,
811
+                array(
812
+                    'meta_key' => '_wpinv_type',
813
+                    'orderby'  => 'meta_value',
814
+                )
815
+            );
816
+        }
817
+
818
+        // By vat class.
819
+        if ( 'vat_class' === $vars['orderby'] ) {
820
+            return array_merge(
821
+                $vars,
822
+                array(
823
+                    'meta_key' => '_wpinv_vat_class',
824
+                    'orderby'  => 'meta_value',
825
+                )
826
+            );
827
+        }
828
+
829
+        // By vat rule.
830
+        if ( 'vat_rule' === $vars['orderby'] ) {
831
+            return array_merge(
832
+                $vars,
833
+                array(
834
+                    'meta_key' => '_wpinv_vat_rule',
835
+                    'orderby'  => 'meta_value',
836
+                )
837
+            );
838
+        }
839
+
840
+        // By price.
841
+        if ( 'price' === $vars['orderby'] ) {
842
+            return array_merge(
843
+                $vars,
844
+                array(
845
+                    'meta_key' => '_wpinv_price',
846
+                    'orderby'  => 'meta_value_num',
847
+                )
848
+            );
849
+        }
850
+
851
+        return $vars;
852
+
853
+    }
854
+
855
+    /**
856
+     * Fired when deleting a post.
857
+     */
858
+    public static function delete_post( $post_id ) {
859
+
860
+        switch ( get_post_type( $post_id ) ) {
861
+
862
+            case 'wpi_item':
863
+                do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) );
864
+                break;
865
+
866
+            case 'wpi_payment_form':
867
+                do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) );
868
+                break;
869
+
870
+            case 'wpi_discount':
871
+                do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) );
872
+                break;
873
+
874
+            case 'wpi_invoice':
875
+                $invoice = new WPInv_Invoice( $post_id );
876
+                do_action( 'getpaid_before_delete_invoice', $invoice );
877
+                $invoice->get_data_store()->delete_items( $invoice );
878
+                $invoice->get_data_store()->delete_special_fields( $invoice );
879
+                break;
880
+        }
881
+    }
882
+
883
+    /**
884 884
      * Add a post display state for special GetPaid pages in the page list table.
885 885
      *
886 886
      * @param array   $post_states An array of post display states.
@@ -894,21 +894,21 @@  discard block
 block discarded – undo
894 894
             $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' );
895 895
         }
896 896
 
897
-		foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
897
+        foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
898 898
 
899
-			if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
900
-				$post_states[ "getpaid_{$post_type}_history_page" ] = sprintf(
901
-					__( 'GetPaid %s History Page', 'invoicing' ),
902
-					$label
903
-				);
904
-			}
899
+            if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
900
+                $post_states[ "getpaid_{$post_type}_history_page" ] = sprintf(
901
+                    __( 'GetPaid %s History Page', 'invoicing' ),
902
+                    $label
903
+                );
904
+            }
905 905
 }
906 906
 
907
-		if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
907
+        if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
908 908
             $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' );
909 909
         }
910 910
 
911
-		if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
911
+        if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
912 912
             $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' );
913 913
         }
914 914
 
Please login to merge, or discard this patch.
Spacing   +252 added lines, -252 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
  * Post types Admin Class
@@ -21,74 +21,74 @@  discard block
 block discarded – undo
21 21
 		GetPaid_Metaboxes::init();
22 22
 
23 23
 		// Filter the post updated messages.
24
-		add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
24
+		add_filter('post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages');
25 25
 
26 26
 		// Filter post actions.
27
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
27
+		add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2);
28
+		add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2);
29 29
 
30 30
 		// Invoice table columns.
31
-		add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
-		add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
-		add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
-		add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
31
+		add_filter('manage_wpi_invoice_posts_columns', array(__CLASS__, 'invoice_columns'), 100);
32
+		add_action('manage_wpi_invoice_posts_custom_column', array(__CLASS__, 'display_invoice_columns'), 10, 2);
33
+		add_filter('bulk_actions-edit-wpi_invoice', array(__CLASS__, 'invoice_bulk_actions'));
34
+		add_filter('handle_bulk_actions-edit-wpi_invoice', array(__CLASS__, 'handle_invoice_bulk_actions'), 10, 3);
35 35
 
36 36
 		// Items table columns.
37
-		add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
-		add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
-		add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
-		add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
-		add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
-		add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
37
+		add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100);
38
+		add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20);
39
+		add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2);
40
+		add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100);
41
+		add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100);
42
+		add_action('request', array(__CLASS__, 'reorder_items'), 100);
43 43
 
44 44
 		// Payment forms columns.
45
-		add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
-		add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
45
+		add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100);
46
+		add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2);
47
+		add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2);
48 48
 
49 49
 		// Discount table columns.
50
-		add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
-		add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
50
+		add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100);
51
+		add_filter('bulk_actions-edit-wpi_discount', '__return_empty_array', 100);
52 52
 
53 53
 		// Deleting posts.
54
-		add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
54
+		add_action('delete_post', array(__CLASS__, 'delete_post'));
55
+		add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2);
56 56
 
57
-		add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
57
+		add_filter('display_post_states', array(__CLASS__, 'add_display_post_states'), 10, 2);
58 58
 	}
59 59
 
60 60
 	/**
61 61
 	 * Post updated messages.
62 62
 	 */
63
-	public static function post_updated_messages( $messages ) {
63
+	public static function post_updated_messages($messages) {
64 64
 		global $post;
65 65
 
66 66
 		$messages['wpi_discount'] = array(
67 67
 			0  => '',
68
-			1  => __( 'Discount updated.', 'invoicing' ),
69
-			2  => __( 'Custom field updated.', 'invoicing' ),
70
-			3  => __( 'Custom field deleted.', 'invoicing' ),
71
-			4  => __( 'Discount updated.', 'invoicing' ),
72
-			5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
-			6  => __( 'Discount updated.', 'invoicing' ),
74
-			7  => __( 'Discount saved.', 'invoicing' ),
75
-			8  => __( 'Discount submitted.', 'invoicing' ),
76
-			9  => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
-			10 => __( 'Discount draft updated.', 'invoicing' ),
68
+			1  => __('Discount updated.', 'invoicing'),
69
+			2  => __('Custom field updated.', 'invoicing'),
70
+			3  => __('Custom field deleted.', 'invoicing'),
71
+			4  => __('Discount updated.', 'invoicing'),
72
+			5  => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false,
73
+			6  => __('Discount updated.', 'invoicing'),
74
+			7  => __('Discount saved.', 'invoicing'),
75
+			8  => __('Discount submitted.', 'invoicing'),
76
+			9  => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
77
+			10 => __('Discount draft updated.', 'invoicing'),
78 78
 		);
79 79
 
80 80
 		$messages['wpi_payment_form'] = array(
81 81
 			0  => '',
82
-			1  => __( 'Payment Form updated.', 'invoicing' ),
83
-			2  => __( 'Custom field updated.', 'invoicing' ),
84
-			3  => __( 'Custom field deleted.', 'invoicing' ),
85
-			4  => __( 'Payment Form updated.', 'invoicing' ),
86
-			5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
-			6  => __( 'Payment Form updated.', 'invoicing' ),
88
-			7  => __( 'Payment Form saved.', 'invoicing' ),
89
-			8  => __( 'Payment Form submitted.', 'invoicing' ),
90
-			9  => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
-			10 => __( 'Payment Form draft updated.', 'invoicing' ),
82
+			1  => __('Payment Form updated.', 'invoicing'),
83
+			2  => __('Custom field updated.', 'invoicing'),
84
+			3  => __('Custom field deleted.', 'invoicing'),
85
+			4  => __('Payment Form updated.', 'invoicing'),
86
+			5  => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false,
87
+			6  => __('Payment Form updated.', 'invoicing'),
88
+			7  => __('Payment Form saved.', 'invoicing'),
89
+			8  => __('Payment Form submitted.', 'invoicing'),
90
+			9  => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
91
+			10 => __('Payment Form draft updated.', 'invoicing'),
92 92
 		);
93 93
 
94 94
 		return $messages;
@@ -98,16 +98,16 @@  discard block
 block discarded – undo
98 98
 	/**
99 99
 	 * Post row actions.
100 100
 	 */
101
-	public static function post_row_actions( $actions, $post ) {
101
+	public static function post_row_actions($actions, $post) {
102 102
 
103
-		$post = get_post( $post );
103
+		$post = get_post($post);
104 104
 
105 105
 		// We do not want to edit the default payment form.
106
-		if ( 'wpi_payment_form' == $post->post_type ) {
106
+		if ('wpi_payment_form' == $post->post_type) {
107 107
 
108
-			if ( wpinv_get_default_payment_form() === $post->ID ) {
109
-				unset( $actions['trash'] );
110
-				unset( $actions['inline hide-if-no-js'] );
108
+			if (wpinv_get_default_payment_form() === $post->ID) {
109
+				unset($actions['trash']);
110
+				unset($actions['inline hide-if-no-js']);
111 111
 			}
112 112
 
113 113
 			$actions['duplicate'] = sprintf(
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 						'getpaid-nonce'
125 125
 					)
126 126
 				),
127
-				esc_html( __( 'Duplicate', 'invoicing' ) )
127
+				esc_html(__('Duplicate', 'invoicing'))
128 128
 			);
129 129
 
130 130
 			$actions['reset'] = sprintf(
@@ -141,17 +141,17 @@  discard block
 block discarded – undo
141 141
 						'getpaid-nonce'
142 142
 					)
143 143
 				),
144
-				esc_html( __( 'Reset Stats', 'invoicing' ) )
144
+				esc_html(__('Reset Stats', 'invoicing'))
145 145
 			);
146 146
 		}
147 147
 
148 148
 		// Link to item payment form.
149
-		if ( 'wpi_item' == $post->post_type ) {
150
-			if ( getpaid_item_type_supports( get_post_meta( $post->ID, '_wpinv_type', true ), 'buy_now' ) ) {
149
+		if ('wpi_item' == $post->post_type) {
150
+			if (getpaid_item_type_supports(get_post_meta($post->ID, '_wpinv_type', true), 'buy_now')) {
151 151
 				$actions['buy'] = sprintf(
152 152
 					'<a href="%1$s">%2$s</a>',
153
-					esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
154
-					esc_html( __( 'Buy', 'invoicing' ) )
153
+					esc_url(getpaid_embed_url(false, $post->ID . '|0')),
154
+					esc_html(__('Buy', 'invoicing'))
155 155
 				);
156 156
 			}
157 157
 		}
@@ -167,28 +167,28 @@  discard block
 block discarded – undo
167 167
 	 * @param WP_Post $post
168 168
      * @return array $actions actions without edit option
169 169
      */
170
-    public static function filter_invoice_row_actions( $actions, $post ) {
170
+    public static function filter_invoice_row_actions($actions, $post) {
171 171
 
172
-        if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
172
+        if (getpaid_is_invoice_post_type($post->post_type)) {
173 173
 
174 174
 			$actions = array();
175
-			$invoice = new WPInv_Invoice( $post );
175
+			$invoice = new WPInv_Invoice($post);
176 176
 
177 177
 			$actions['edit'] = sprintf(
178 178
 				'<a href="%1$s">%2$s</a>',
179
-				esc_url( get_edit_post_link( $invoice->get_id() ) ),
180
-				esc_html( __( 'Edit', 'invoicing' ) )
179
+				esc_url(get_edit_post_link($invoice->get_id())),
180
+				esc_html(__('Edit', 'invoicing'))
181 181
 			);
182 182
 
183
-			if ( ! $invoice->is_draft() ) {
183
+			if (!$invoice->is_draft()) {
184 184
 
185 185
 				$actions['view'] = sprintf(
186 186
 					'<a href="%1$s">%2$s</a>',
187
-					esc_url( $invoice->get_view_url() ),
187
+					esc_url($invoice->get_view_url()),
188 188
 					sprintf(
189 189
 						// translators: %s is the invoice type
190
-						esc_html__( 'View %s', 'invoicing' ),
191
-						getpaid_get_post_type_label( $invoice->get_post_type(), false )
190
+						esc_html__('View %s', 'invoicing'),
191
+						getpaid_get_post_type_label($invoice->get_post_type(), false)
192 192
 					)
193 193
 				);
194 194
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 							'getpaid-nonce'
207 207
 						)
208 208
 					),
209
-					esc_html( __( 'Send to Customer', 'invoicing' ) )
209
+					esc_html(__('Send to Customer', 'invoicing'))
210 210
 				);
211 211
 
212 212
 			}
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 						'getpaid-nonce'
226 226
 					)
227 227
 				),
228
-				esc_html( __( 'Duplicate', 'invoicing' ) )
228
+				esc_html(__('Duplicate', 'invoicing'))
229 229
 			);
230 230
 
231 231
         }
@@ -236,59 +236,59 @@  discard block
 block discarded – undo
236 236
 	/**
237 237
 	 * Returns an array of invoice table columns.
238 238
 	 */
239
-	public static function invoice_columns( $columns ) {
239
+	public static function invoice_columns($columns) {
240 240
 
241 241
 		$columns = array(
242 242
 			'cb'           => $columns['cb'],
243
-			'number'       => __( 'Invoice', 'invoicing' ),
244
-			'customer'     => __( 'Customer', 'invoicing' ),
245
-			'invoice_date' => __( 'Created', 'invoicing' ),
246
-			'payment_date' => __( 'Completed', 'invoicing' ),
247
-			'amount'       => __( 'Amount', 'invoicing' ),
248
-			'recurring'    => __( 'Recurring', 'invoicing' ),
249
-			'status'       => __( 'Status', 'invoicing' ),
243
+			'number'       => __('Invoice', 'invoicing'),
244
+			'customer'     => __('Customer', 'invoicing'),
245
+			'invoice_date' => __('Created', 'invoicing'),
246
+			'payment_date' => __('Completed', 'invoicing'),
247
+			'amount'       => __('Amount', 'invoicing'),
248
+			'recurring'    => __('Recurring', 'invoicing'),
249
+			'status'       => __('Status', 'invoicing'),
250 250
 		);
251 251
 
252
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
252
+		return apply_filters('wpi_invoice_table_columns', $columns);
253 253
 	}
254 254
 
255 255
 	/**
256 256
 	 * Displays invoice table columns.
257 257
 	 */
258
-	public static function display_invoice_columns( $column_name, $post_id ) {
258
+	public static function display_invoice_columns($column_name, $post_id) {
259 259
 
260
-		$invoice = new WPInv_Invoice( $post_id );
260
+		$invoice = new WPInv_Invoice($post_id);
261 261
 
262
-		switch ( $column_name ) {
262
+		switch ($column_name) {
263 263
 
264 264
 			case 'invoice_date':
265
-				$date_time = esc_attr( $invoice->get_created_date() );
266
-				$date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
267
-				echo wp_kses_post( "<span title='$date_time'>$date</span>" );
265
+				$date_time = esc_attr($invoice->get_created_date());
266
+				$date      = esc_html(getpaid_format_date_value($date_time, '&mdash;', true));
267
+				echo wp_kses_post("<span title='$date_time'>$date</span>");
268 268
 				break;
269 269
 
270 270
 			case 'payment_date':
271
-				if ( $invoice->is_paid() || $invoice->is_refunded() ) {
272
-					$date_time = esc_attr( $invoice->get_completed_date() );
273
-					$date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
274
-					echo wp_kses_post( "<span title='$date_time'>$date</span>" );
271
+				if ($invoice->is_paid() || $invoice->is_refunded()) {
272
+					$date_time = esc_attr($invoice->get_completed_date());
273
+					$date      = esc_html(getpaid_format_date_value($date_time, '&mdash;', true));
274
+					echo wp_kses_post("<span title='$date_time'>$date</span>");
275 275
 
276
-					if ( $_gateway = $invoice->get_gateway() ) {
277
-						$gateway_label = wpinv_get_gateway_admin_label( $_gateway );
276
+					if ($_gateway = $invoice->get_gateway()) {
277
+						$gateway_label = wpinv_get_gateway_admin_label($_gateway);
278 278
 
279
-						if ( $transaction_url = $invoice->get_transaction_url() ) {
280
-							$gateway_label = '<a href="' . esc_url( $transaction_url ) . '" target="_blank" title="' . esc_attr__( 'Open transaction link', 'invoicing' ) . '">' . $gateway_label . '</a>';
279
+						if ($transaction_url = $invoice->get_transaction_url()) {
280
+							$gateway_label = '<a href="' . esc_url($transaction_url) . '" target="_blank" title="' . esc_attr__('Open transaction link', 'invoicing') . '">' . $gateway_label . '</a>';
281 281
 						}
282 282
 
283
-						$gateway = '<small class="meta bsui"><span class="fs-xs text-muted fst-normal">' . wp_sprintf( _x( 'Via %s', 'Paid via gateway', 'invoicing' ), $gateway_label ) . '</span></small>';
283
+						$gateway = '<small class="meta bsui"><span class="fs-xs text-muted fst-normal">' . wp_sprintf(_x('Via %s', 'Paid via gateway', 'invoicing'), $gateway_label) . '</span></small>';
284 284
 					} else {
285 285
 						$gateway = '';
286 286
 					}
287 287
 
288
-					$gateway = apply_filters( 'getpaid_admin_invoices_list_table_gateway', $gateway, $invoice );
288
+					$gateway = apply_filters('getpaid_admin_invoices_list_table_gateway', $gateway, $invoice);
289 289
 
290
-					if ( $gateway ) {
291
-						echo wp_kses_post( $gateway ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
290
+					if ($gateway) {
291
+						echo wp_kses_post($gateway); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
292 292
 					}
293 293
 				} else {
294 294
 					echo '&mdash;';
@@ -298,60 +298,60 @@  discard block
 block discarded – undo
298 298
 
299 299
 			case 'amount':
300 300
 				$amount = $invoice->get_total();
301
-				$formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) );
301
+				$formated_amount = wp_kses_post(wpinv_price($amount, $invoice->get_currency()));
302 302
 
303
-				if ( $invoice->is_refunded() ) {
304
-					$refunded_amount = wpinv_price( 0, $invoice->get_currency() );
305
-					echo wp_kses_post( "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>" );
303
+				if ($invoice->is_refunded()) {
304
+					$refunded_amount = wpinv_price(0, $invoice->get_currency());
305
+					echo wp_kses_post("<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>");
306 306
 				} else {
307 307
 
308 308
 					$discount = $invoice->get_total_discount();
309 309
 
310
-					if ( ! empty( $discount ) ) {
311
-						$new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
312
-						echo wp_kses_post( "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>" );
310
+					if (!empty($discount)) {
311
+						$new_amount = wpinv_price($amount + $discount, $invoice->get_currency());
312
+						echo wp_kses_post("<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>");
313 313
 					} else {
314
-						echo wp_kses_post( $formated_amount );
314
+						echo wp_kses_post($formated_amount);
315 315
 					}
316 316
 				}
317 317
 
318 318
 				break;
319 319
 
320 320
 			case 'status':
321
-				$status = esc_html( $invoice->get_status() );
321
+				$status = esc_html($invoice->get_status());
322 322
 
323 323
 				// If it is paid, show the gateway title.
324
-				if ( $invoice->is_paid() ) {
325
-					$gateway = esc_html( $invoice->get_gateway_title() );
326
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) );
324
+				if ($invoice->is_paid()) {
325
+					$gateway = esc_html($invoice->get_gateway_title());
326
+					$gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), esc_html($gateway));
327 327
 
328
-					echo wp_kses_post( "<span class='bsui wpi-help-tip getpaid-invoice-statuss $status' title='$gateway'><span class='fs-base'>" . $invoice->get_status_label_html() . "</span></span>" );
328
+					echo wp_kses_post("<span class='bsui wpi-help-tip getpaid-invoice-statuss $status' title='$gateway'><span class='fs-base'>" . $invoice->get_status_label_html() . "</span></span>");
329 329
 				} else {
330
-					echo wp_kses_post( "<span class='bsui getpaid-invoice-statuss $status'><span class='fs-base'>" . $invoice->get_status_label_html() . "</span></span>" );
330
+					echo wp_kses_post("<span class='bsui getpaid-invoice-statuss $status'><span class='fs-base'>" . $invoice->get_status_label_html() . "</span></span>");
331 331
 				}
332 332
 
333 333
 				// If it is not paid, display the overdue and view status.
334
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
334
+				if (!$invoice->is_paid() && !$invoice->is_refunded()) {
335 335
 
336 336
 					// Invoice view status.
337
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
338
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>';
337
+					if (wpinv_is_invoice_viewed($invoice->get_id())) {
338
+						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>';
339 339
 					} else {
340
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>';
340
+						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>';
341 341
 					}
342 342
 
343 343
 					// Display the overview status.
344
-					if ( wpinv_get_option( 'overdue_active' ) ) {
344
+					if (wpinv_get_option('overdue_active')) {
345 345
 						$due_date = $invoice->get_due_date();
346
-						$fomatted = getpaid_format_date( $due_date );
346
+						$fomatted = getpaid_format_date($due_date);
347 347
 
348
-						if ( ! empty( $fomatted ) ) {
348
+						if (!empty($fomatted)) {
349 349
 							$date = wp_sprintf(
350 350
 								// translators: %s is the due date.
351
-								__( 'Due %s', 'invoicing' ),
351
+								__('Due %s', 'invoicing'),
352 352
 								$fomatted
353 353
 							);
354
-							echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" );
354
+							echo wp_kses_post("<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>");
355 355
 						}
356 356
 					}
357 357
 				}
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 				break;
360 360
 
361 361
 			case 'recurring':
362
-				if ( $invoice->is_recurring() ) {
362
+				if ($invoice->is_recurring()) {
363 363
 					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
364 364
 				} else {
365 365
 					echo '<i class="fa fa-times" style="color:#616161;"></i>';
@@ -367,26 +367,26 @@  discard block
 block discarded – undo
367 367
 				break;
368 368
 
369 369
 			case 'number':
370
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
371
-				$invoice_number  = esc_html( $invoice->get_number() );
372
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
370
+				$edit_link       = esc_url(get_edit_post_link($invoice->get_id()));
371
+				$invoice_number  = esc_html($invoice->get_number());
372
+				$invoice_details = esc_attr__('View Invoice Details', 'invoicing');
373 373
 
374
-				echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" );
374
+				echo wp_kses_post("<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>");
375 375
 
376
-				do_action( 'getpaid_admin_table_invoice_number_column', $invoice );
376
+				do_action('getpaid_admin_table_invoice_number_column', $invoice);
377 377
 				break;
378 378
 
379 379
 			case 'customer':
380 380
 				$customer_name = $invoice->get_user_full_name();
381 381
 
382
-				if ( empty( $customer_name ) ) {
382
+				if (empty($customer_name)) {
383 383
 					$customer_name = $invoice->get_email();
384 384
 				}
385 385
 
386
-				if ( ! empty( $customer_name ) ) {
387
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
388
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
389
-					echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" );
386
+				if (!empty($customer_name)) {
387
+					$customer_details = esc_attr__('View Customer Details', 'invoicing');
388
+					$view_link        = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php')));
389
+					echo wp_kses_post("<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>");
390 390
 				} else {
391 391
 					echo '<div>&mdash;</div>';
392 392
 				}
@@ -400,19 +400,19 @@  discard block
 block discarded – undo
400 400
 	/**
401 401
 	 * Displays invoice bulk actions.
402 402
 	 */
403
-	public static function invoice_bulk_actions( $actions ) {
404
-		$actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
403
+	public static function invoice_bulk_actions($actions) {
404
+		$actions['resend-invoice'] = __('Send to Customer', 'invoicing');
405 405
 		return $actions;
406 406
 	}
407 407
 
408 408
 	/**
409 409
 	 * Processes invoice bulk actions.
410 410
 	 */
411
-	public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
411
+	public static function handle_invoice_bulk_actions($redirect_url, $action, $post_ids) {
412 412
 
413
-		if ( 'resend-invoice' === $action ) {
414
-			foreach ( $post_ids as $post_id ) {
415
-				getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
413
+		if ('resend-invoice' === $action) {
414
+			foreach ($post_ids as $post_id) {
415
+				getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($post_id), true);
416 416
 			}
417 417
 		}
418 418
 
@@ -423,49 +423,49 @@  discard block
 block discarded – undo
423 423
 	/**
424 424
 	 * Returns an array of payment forms table columns.
425 425
 	 */
426
-	public static function payment_form_columns( $columns ) {
426
+	public static function payment_form_columns($columns) {
427 427
 
428 428
 		$columns = array(
429 429
 			'cb'        => $columns['cb'],
430
-			'title'     => __( 'Name', 'invoicing' ),
431
-			'shortcode' => __( 'Shortcode', 'invoicing' ),
432
-			'earnings'  => __( 'Revenue', 'invoicing' ),
433
-			'refunds'   => __( 'Refunded', 'invoicing' ),
434
-			'items'     => __( 'Items', 'invoicing' ),
435
-			'date'      => __( 'Date', 'invoicing' ),
430
+			'title'     => __('Name', 'invoicing'),
431
+			'shortcode' => __('Shortcode', 'invoicing'),
432
+			'earnings'  => __('Revenue', 'invoicing'),
433
+			'refunds'   => __('Refunded', 'invoicing'),
434
+			'items'     => __('Items', 'invoicing'),
435
+			'date'      => __('Date', 'invoicing'),
436 436
 		);
437 437
 
438
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
438
+		return apply_filters('wpi_payment_form_table_columns', $columns);
439 439
 
440 440
 	}
441 441
 
442 442
 	/**
443 443
 	 * Displays payment form table columns.
444 444
 	 */
445
-	public static function display_payment_form_columns( $column_name, $post_id ) {
445
+	public static function display_payment_form_columns($column_name, $post_id) {
446 446
 
447 447
 		// Retrieve the payment form.
448
-		$form = new GetPaid_Payment_Form( $post_id );
448
+		$form = new GetPaid_Payment_Form($post_id);
449 449
 
450
-		switch ( $column_name ) {
450
+		switch ($column_name) {
451 451
 
452 452
 			case 'earnings':
453
-				echo wp_kses_post( wpinv_price( $form->get_earned() ) );
453
+				echo wp_kses_post(wpinv_price($form->get_earned()));
454 454
 				break;
455 455
 
456 456
 			case 'refunds':
457
-				echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
457
+				echo wp_kses_post(wpinv_price($form->get_refunded()));
458 458
 				break;
459 459
 
460 460
 			case 'refunds':
461
-				echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
461
+				echo wp_kses_post(wpinv_price($form->get_refunded()));
462 462
 				break;
463 463
 
464 464
 			case 'shortcode':
465
-				if ( $form->is_default() ) {
465
+				if ($form->is_default()) {
466 466
 					echo '&mdash;';
467 467
 				} else {
468
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
468
+					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>';
469 469
 				}
470 470
 
471 471
 				break;
@@ -473,28 +473,28 @@  discard block
 block discarded – undo
473 473
 			case 'items':
474 474
 				$items = $form->get_items();
475 475
 
476
-				if ( $form->is_default() || empty( $items ) ) {
476
+				if ($form->is_default() || empty($items)) {
477 477
 					echo '&mdash;';
478 478
 					return;
479 479
 				}
480 480
 
481 481
 				$_items = array();
482 482
 
483
-				foreach ( $items as $item ) {
483
+				foreach ($items as $item) {
484 484
 					$url = $item->get_edit_url();
485 485
 
486
-					if ( empty( $url ) ) {
487
-						$_items[] = esc_html( $item->get_name() );
486
+					if (empty($url)) {
487
+						$_items[] = esc_html($item->get_name());
488 488
 					} else {
489 489
 						$_items[] = sprintf(
490 490
 							'<a href="%s">%s</a>',
491
-							esc_url( $url ),
492
-							esc_html( $item->get_name() )
491
+							esc_url($url),
492
+							esc_html($item->get_name())
493 493
 						);
494 494
 					}
495 495
 }
496 496
 
497
-				echo wp_kses_post( implode( '<br>', $_items ) );
497
+				echo wp_kses_post(implode('<br>', $_items));
498 498
 
499 499
 				break;
500 500
 
@@ -505,10 +505,10 @@  discard block
 block discarded – undo
505 505
 	/**
506 506
 	 * Filters post states.
507 507
 	 */
508
-	public static function filter_payment_form_state( $post_states, $post ) {
508
+	public static function filter_payment_form_state($post_states, $post) {
509 509
 
510
-		if ( 'wpi_payment_form' === $post->post_type && wpinv_get_default_payment_form() === $post->ID ) {
511
-			$post_states['default_form'] = __( 'Default Payment Form', 'invoicing' );
510
+		if ('wpi_payment_form' === $post->post_type && wpinv_get_default_payment_form() === $post->ID) {
511
+			$post_states['default_form'] = __('Default Payment Form', 'invoicing');
512 512
 		}
513 513
 
514 514
 		return $post_states;
@@ -518,35 +518,35 @@  discard block
 block discarded – undo
518 518
 	/**
519 519
 	 * Returns an array of coupon table columns.
520 520
 	 */
521
-	public static function discount_columns( $columns ) {
521
+	public static function discount_columns($columns) {
522 522
 
523 523
 		$columns = array(
524 524
 			'cb'          => $columns['cb'],
525
-			'title'       => __( 'Name', 'invoicing' ),
526
-			'code'        => __( 'Code', 'invoicing' ),
527
-			'amount'      => __( 'Amount', 'invoicing' ),
528
-			'usage'       => __( 'Usage / Limit', 'invoicing' ),
529
-			'start_date'  => __( 'Start Date', 'invoicing' ),
530
-			'expiry_date' => __( 'Expiry Date', 'invoicing' ),
525
+			'title'       => __('Name', 'invoicing'),
526
+			'code'        => __('Code', 'invoicing'),
527
+			'amount'      => __('Amount', 'invoicing'),
528
+			'usage'       => __('Usage / Limit', 'invoicing'),
529
+			'start_date'  => __('Start Date', 'invoicing'),
530
+			'expiry_date' => __('Expiry Date', 'invoicing'),
531 531
 		);
532 532
 
533
-		return apply_filters( 'wpi_discount_table_columns', $columns );
533
+		return apply_filters('wpi_discount_table_columns', $columns);
534 534
 	}
535 535
 
536 536
 	/**
537 537
 	 * Filters post states.
538 538
 	 */
539
-	public static function filter_discount_state( $post_states, $post ) {
539
+	public static function filter_discount_state($post_states, $post) {
540 540
 
541
-		if ( 'wpi_discount' === $post->post_type ) {
541
+		if ('wpi_discount' === $post->post_type) {
542 542
 
543
-			$discount = new WPInv_Discount( $post );
543
+			$discount = new WPInv_Discount($post);
544 544
 
545 545
 			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
546 546
 
547
-			if ( 'publish' !== $status ) {
547
+			if ('publish' !== $status) {
548 548
 				return array(
549
-					'discount_status' => wpinv_discount_status( $status ),
549
+					'discount_status' => wpinv_discount_status($status),
550 550
 				);
551 551
 			}
552 552
 
@@ -561,30 +561,30 @@  discard block
 block discarded – undo
561 561
 	/**
562 562
 	 * Returns an array of items table columns.
563 563
 	 */
564
-	public static function item_columns( $columns ) {
564
+	public static function item_columns($columns) {
565 565
 
566 566
 		$columns = array(
567 567
 			'cb'        => $columns['cb'],
568
-			'title'     => __( 'Name', 'invoicing' ),
569
-			'price'     => __( 'Price', 'invoicing' ),
570
-			'vat_rule'  => __( 'Tax Rule', 'invoicing' ),
571
-			'vat_class' => __( 'Tax Class', 'invoicing' ),
572
-			'type'      => __( 'Type', 'invoicing' ),
573
-			'shortcode' => __( 'Shortcode', 'invoicing' ),
568
+			'title'     => __('Name', 'invoicing'),
569
+			'price'     => __('Price', 'invoicing'),
570
+			'vat_rule'  => __('Tax Rule', 'invoicing'),
571
+			'vat_class' => __('Tax Class', 'invoicing'),
572
+			'type'      => __('Type', 'invoicing'),
573
+			'shortcode' => __('Shortcode', 'invoicing'),
574 574
 		);
575 575
 
576
-		if ( ! wpinv_use_taxes() ) {
577
-			unset( $columns['vat_rule'] );
578
-			unset( $columns['vat_class'] );
576
+		if (!wpinv_use_taxes()) {
577
+			unset($columns['vat_rule']);
578
+			unset($columns['vat_class']);
579 579
 		}
580 580
 
581
-		return apply_filters( 'wpi_item_table_columns', $columns );
581
+		return apply_filters('wpi_item_table_columns', $columns);
582 582
 	}
583 583
 
584 584
 	/**
585 585
 	 * Returns an array of sortable items table columns.
586 586
 	 */
587
-	public static function sortable_item_columns( $columns ) {
587
+	public static function sortable_item_columns($columns) {
588 588
 
589 589
 		return array_merge(
590 590
 			$columns,
@@ -601,45 +601,45 @@  discard block
 block discarded – undo
601 601
 	/**
602 602
 	 * Displays items table columns.
603 603
 	 */
604
-	public static function display_item_columns( $column_name, $post_id ) {
604
+	public static function display_item_columns($column_name, $post_id) {
605 605
 
606
-		$item = new WPInv_Item( $post_id );
606
+		$item = new WPInv_Item($post_id);
607 607
 
608
-		switch ( $column_name ) {
608
+		switch ($column_name) {
609 609
 
610 610
 			case 'price':
611
-				if ( ! $item->is_recurring() ) {
612
-					echo wp_kses_post( $item->get_the_price() );
611
+				if (!$item->is_recurring()) {
612
+					echo wp_kses_post($item->get_the_price());
613 613
 					break;
614 614
 				}
615 615
 
616 616
 				$price = wp_sprintf(
617
-					__( '%1$s / %2$s', 'invoicing' ),
617
+					__('%1$s / %2$s', 'invoicing'),
618 618
 					$item->get_the_price(),
619
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
619
+					getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '')
620 620
 				);
621 621
 
622
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
623
-					echo wp_kses_post( $price );
622
+				if ($item->get_the_price() == $item->get_the_initial_price()) {
623
+					echo wp_kses_post($price);
624 624
 					break;
625 625
 				}
626 626
 
627
-				echo wp_kses_post( $item->get_the_initial_price() );
627
+				echo wp_kses_post($item->get_the_initial_price());
628 628
 
629
-				echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>';
629
+				echo '<span class="meta">' . wp_sprintf(esc_html__('then %s', 'invoicing'), wp_kses_post($price)) . '</span>';
630 630
 				break;
631 631
 
632 632
 			case 'vat_rule':
633
-				echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) );
633
+				echo wp_kses_post(getpaid_get_tax_rule_label($item->get_vat_rule()));
634 634
 				break;
635 635
 
636 636
 			case 'vat_class':
637
-				echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) );
637
+				echo wp_kses_post(getpaid_get_tax_class_label($item->get_vat_class()));
638 638
 				break;
639 639
 
640 640
 			case 'shortcode':
641
-				if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
642
-					echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
641
+				if ($item->is_type(array('', 'fee', 'custom'))) {
642
+					echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
643 643
 				} else {
644 644
 					echo '&mdash;';
645 645
 				}
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
 				break;
648 648
 
649 649
 			case 'type':
650
-				echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' );
650
+				echo wp_kses_post(wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>');
651 651
 				break;
652 652
 
653 653
 		}
@@ -657,21 +657,21 @@  discard block
 block discarded – undo
657 657
 	/**
658 658
 	 * Lets users filter items using taxes.
659 659
 	 */
660
-	public static function add_item_filters( $post_type ) {
660
+	public static function add_item_filters($post_type) {
661 661
 
662 662
 		// Abort if we're not dealing with items.
663
-		if ( 'wpi_item' !== $post_type ) {
663
+		if ('wpi_item' !== $post_type) {
664 664
 			return;
665 665
 		}
666 666
 
667 667
 		// Filter by vat rules.
668
-		if ( wpinv_use_taxes() ) {
668
+		if (wpinv_use_taxes()) {
669 669
 
670 670
 			// Sanitize selected vat rule.
671 671
 			$vat_rule   = '';
672 672
 			$vat_rules  = getpaid_get_tax_rules();
673
-			if ( isset( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
674
-				$vat_rule   = sanitize_text_field( $_GET['vat_rule'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
673
+			if (isset($_GET['vat_rule'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
674
+				$vat_rule = sanitize_text_field($_GET['vat_rule']); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
675 675
 			}
676 676
 
677 677
 			// Filter by VAT rule.
@@ -679,13 +679,13 @@  discard block
 block discarded – undo
679 679
 				array(
680 680
 					'options'          => array_merge(
681 681
 						array(
682
-							'' => __( 'All Tax Rules', 'invoicing' ),
682
+							'' => __('All Tax Rules', 'invoicing'),
683 683
 						),
684 684
 						$vat_rules
685 685
 					),
686 686
 					'name'             => 'vat_rule',
687 687
 					'id'               => 'vat_rule',
688
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ), true ) ? $vat_rule : '',
688
+					'selected'         => in_array($vat_rule, array_keys($vat_rules), true) ? $vat_rule : '',
689 689
 					'show_option_all'  => false,
690 690
 					'show_option_none' => false,
691 691
 				)
@@ -696,21 +696,21 @@  discard block
 block discarded – undo
696 696
 			// Sanitize selected vat rule.
697 697
 			$vat_class   = '';
698 698
 			$vat_classes = getpaid_get_tax_classes();
699
-			if ( isset( $_GET['vat_class'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
700
-				$vat_class   = sanitize_text_field( $_GET['vat_class'] );  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
699
+			if (isset($_GET['vat_class'])) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
700
+				$vat_class = sanitize_text_field($_GET['vat_class']); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
701 701
 			}
702 702
 
703 703
 			wpinv_html_select(
704 704
 				array(
705 705
 					'options'          => array_merge(
706 706
 						array(
707
-							'' => __( 'All Tax Classes', 'invoicing' ),
707
+							'' => __('All Tax Classes', 'invoicing'),
708 708
 						),
709 709
 						$vat_classes
710 710
 					),
711 711
 					'name'             => 'vat_class',
712 712
 					'id'               => 'vat_class',
713
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ), true ) ? $vat_class : '',
713
+					'selected'         => in_array($vat_class, array_keys($vat_classes), true) ? $vat_class : '',
714 714
 					'show_option_all'  => false,
715 715
 					'show_option_none' => false,
716 716
 				)
@@ -719,22 +719,22 @@  discard block
 block discarded – undo
719 719
 		}
720 720
 
721 721
 		// Filter by item type.
722
-		$type   = '';
723
-		if ( isset( $_GET['type'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
724
-			$type   = sanitize_text_field( $_GET['type'] );  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
722
+		$type = '';
723
+		if (isset($_GET['type'])) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
724
+			$type = sanitize_text_field($_GET['type']); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
725 725
 		}
726 726
 
727 727
 		wpinv_html_select(
728 728
 			array(
729 729
 				'options'          => array_merge(
730 730
 					array(
731
-						'' => __( 'All item types', 'invoicing' ),
731
+						'' => __('All item types', 'invoicing'),
732 732
 					),
733 733
 					wpinv_get_item_types()
734 734
 				),
735 735
 				'name'             => 'type',
736 736
 				'id'               => 'type',
737
-				'selected'         => in_array( $type, wpinv_item_types(), true ) ? $type : '',
737
+				'selected'         => in_array($type, wpinv_item_types(), true) ? $type : '',
738 738
 				'show_option_all'  => false,
739 739
 				'show_option_none' => false,
740 740
 			)
@@ -745,45 +745,45 @@  discard block
 block discarded – undo
745 745
 	/**
746 746
 	 * Filters the item query.
747 747
 	 */
748
-	public static function filter_item_query( $query ) {
748
+	public static function filter_item_query($query) {
749 749
 
750 750
 		// modify the query only if it admin and main query.
751
-		if ( ! ( is_admin() && $query->is_main_query() ) ) {
751
+		if (!(is_admin() && $query->is_main_query())) {
752 752
 			return $query;
753 753
 		}
754 754
 
755 755
 		// we want to modify the query for our items.
756
-		if ( empty( $query->query['post_type'] ) || 'wpi_item' !== $query->query['post_type'] ) {
756
+		if (empty($query->query['post_type']) || 'wpi_item' !== $query->query['post_type']) {
757 757
 			return $query;
758 758
 		}
759 759
 
760
-		if ( empty( $query->query_vars['meta_query'] ) ) {
760
+		if (empty($query->query_vars['meta_query'])) {
761 761
 			$query->query_vars['meta_query'] = array();
762 762
 		}
763 763
 
764 764
 		// Filter vat rule type
765
-        if ( ! empty( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
765
+        if (!empty($_GET['vat_rule'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
766 766
             $query->query_vars['meta_query'][] = array(
767 767
                 'key'     => '_wpinv_vat_rule',
768
-                'value'   => sanitize_text_field( $_GET['vat_rule'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended
768
+                'value'   => sanitize_text_field($_GET['vat_rule']), // phpcs:ignore WordPress.Security.NonceVerification.Recommended
769 769
                 'compare' => '=',
770 770
             );
771 771
         }
772 772
 
773 773
         // Filter vat class
774
-        if ( ! empty( $_GET['vat_class'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
774
+        if (!empty($_GET['vat_class'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
775 775
             $query->query_vars['meta_query'][] = array(
776 776
                 'key'     => '_wpinv_vat_class',
777
-                'value'   => sanitize_text_field( $_GET['vat_class'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended
777
+                'value'   => sanitize_text_field($_GET['vat_class']), // phpcs:ignore WordPress.Security.NonceVerification.Recommended
778 778
                 'compare' => '=',
779 779
             );
780 780
         }
781 781
 
782 782
         // Filter item type
783
-        if ( ! empty( $_GET['type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
783
+        if (!empty($_GET['type'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
784 784
             $query->query_vars['meta_query'][] = array(
785 785
                 'key'     => '_wpinv_type',
786
-                'value'   => sanitize_text_field( $_GET['type'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended
786
+                'value'   => sanitize_text_field($_GET['type']), // phpcs:ignore WordPress.Security.NonceVerification.Recommended
787 787
                 'compare' => '=',
788 788
             );
789 789
 		}
@@ -797,15 +797,15 @@  discard block
 block discarded – undo
797 797
 	/**
798 798
 	 * Reorders items.
799 799
 	 */
800
-	public static function reorder_items( $vars ) {
800
+	public static function reorder_items($vars) {
801 801
 		global $typenow;
802 802
 
803
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
803
+		if ('wpi_item' !== $typenow || empty($vars['orderby'])) {
804 804
 			return $vars;
805 805
 		}
806 806
 
807 807
 		// By item type.
808
-		if ( 'type' === $vars['orderby'] ) {
808
+		if ('type' === $vars['orderby']) {
809 809
 			return array_merge(
810 810
 				$vars,
811 811
 				array(
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
 		}
817 817
 
818 818
 		// By vat class.
819
-		if ( 'vat_class' === $vars['orderby'] ) {
819
+		if ('vat_class' === $vars['orderby']) {
820 820
 			return array_merge(
821 821
 				$vars,
822 822
 				array(
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 		}
828 828
 
829 829
 		// By vat rule.
830
-		if ( 'vat_rule' === $vars['orderby'] ) {
830
+		if ('vat_rule' === $vars['orderby']) {
831 831
 			return array_merge(
832 832
 				$vars,
833 833
 				array(
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
 		}
839 839
 
840 840
 		// By price.
841
-		if ( 'price' === $vars['orderby'] ) {
841
+		if ('price' === $vars['orderby']) {
842 842
 			return array_merge(
843 843
 				$vars,
844 844
 				array(
@@ -855,27 +855,27 @@  discard block
 block discarded – undo
855 855
 	/**
856 856
 	 * Fired when deleting a post.
857 857
 	 */
858
-	public static function delete_post( $post_id ) {
858
+	public static function delete_post($post_id) {
859 859
 
860
-		switch ( get_post_type( $post_id ) ) {
860
+		switch (get_post_type($post_id)) {
861 861
 
862 862
 			case 'wpi_item':
863
-				do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) );
863
+				do_action('getpaid_before_delete_item', new WPInv_Item($post_id));
864 864
 				break;
865 865
 
866 866
 			case 'wpi_payment_form':
867
-				do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) );
867
+				do_action('getpaid_before_delete_payment_form', new GetPaid_Payment_Form($post_id));
868 868
 				break;
869 869
 
870 870
 			case 'wpi_discount':
871
-				do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) );
871
+				do_action('getpaid_before_delete_discount', new WPInv_Discount($post_id));
872 872
 				break;
873 873
 
874 874
 			case 'wpi_invoice':
875
-				$invoice = new WPInv_Invoice( $post_id );
876
-				do_action( 'getpaid_before_delete_invoice', $invoice );
877
-				$invoice->get_data_store()->delete_items( $invoice );
878
-				$invoice->get_data_store()->delete_special_fields( $invoice );
875
+				$invoice = new WPInv_Invoice($post_id);
876
+				do_action('getpaid_before_delete_invoice', $invoice);
877
+				$invoice->get_data_store()->delete_items($invoice);
878
+				$invoice->get_data_store()->delete_special_fields($invoice);
879 879
 				break;
880 880
 		}
881 881
 	}
@@ -888,28 +888,28 @@  discard block
 block discarded – undo
888 888
      *
889 889
      * @return mixed
890 890
      */
891
-    public static function add_display_post_states( $post_states, $post ) {
891
+    public static function add_display_post_states($post_states, $post) {
892 892
 
893
-        if ( wpinv_get_option( 'success_page', 0 ) == $post->ID ) {
894
-            $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' );
893
+        if (wpinv_get_option('success_page', 0) == $post->ID) {
894
+            $post_states['getpaid_success_page'] = __('GetPaid Receipt Page', 'invoicing');
895 895
         }
896 896
 
897
-		foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
897
+		foreach (getpaid_get_invoice_post_types() as $post_type => $label) {
898 898
 
899
-			if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
900
-				$post_states[ "getpaid_{$post_type}_history_page" ] = sprintf(
901
-					__( 'GetPaid %s History Page', 'invoicing' ),
899
+			if (wpinv_get_option("{$post_type}_history_page", 0) == $post->ID) {
900
+				$post_states["getpaid_{$post_type}_history_page"] = sprintf(
901
+					__('GetPaid %s History Page', 'invoicing'),
902 902
 					$label
903 903
 				);
904 904
 			}
905 905
 }
906 906
 
907
-		if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
908
-            $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' );
907
+		if (wpinv_get_option('invoice_subscription_page', 0) == $post->ID) {
908
+            $post_states['getpaid_invoice_subscription_page'] = __('GetPaid Subscription Page', 'invoicing');
909 909
         }
910 910
 
911
-		if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
912
-            $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' );
911
+		if (wpinv_get_option('checkout_page', 0) == $post->ID) {
912
+            $post_states['getpaid_checkout_page'] = __('GetPaid Checkout Page', 'invoicing');
913 913
         }
914 914
 
915 915
         return $post_states;
Please login to merge, or discard this patch.