Passed
Push — master ( 0cc6c6...451f1a )
by Brian
06:48 queued 27s
created
templates/payment-forms/elements/file_upload.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -21,22 +21,22 @@
 block discarded – undo
21 21
 
22 22
 foreach ( $file_types as $file_type ) {
23 23
 
24
-	if ( isset( $all_types[ $file_type ] ) ) {
25
-		$types[]   = $all_types[ $file_type ];
26
-		$file_type = explode( '|', $file_type );
24
+    if ( isset( $all_types[ $file_type ] ) ) {
25
+        $types[]   = $all_types[ $file_type ];
26
+        $file_type = explode( '|', $file_type );
27 27
 
28
-		foreach ( $file_type as $type ) {
29
-			$type     = trim( $type );
30
-			$types[]  = ".$type";
31
-			$_types[] = $type;
32
-		}
28
+        foreach ( $file_type as $type ) {
29
+            $type     = trim( $type );
30
+            $types[]  = ".$type";
31
+            $_types[] = $type;
32
+        }
33 33
 
34
-	}
34
+    }
35 35
 
36 36
 }
37 37
 
38 38
 if ( ! empty( $required ) ) {
39
-	$label .= "<span class='text-danger'> *</span>";
39
+    $label .= "<span class='text-danger'> *</span>";
40 40
 }
41 41
 
42 42
 ?>
Please login to merge, or discard this patch.
templates/payment-forms/embed.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,32 +1,32 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-	// Is the request set up correctly?
4
-	if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) {
5
-		return aui()->alert(
6
-			array(
7
-				'type'    => 'warning',
8
-				'content' => __( 'No payment form or item selected', 'invoicing' ),
9
-			)
10
-		);
11
-		wp_die( __( 'No payment form or item selected', 'invoicing' ), 400 );
12
-	}
13
-
14
-	// Payment form or button?
15
-	if ( ! empty( $_GET['form'] ) ) {
16
-
17
-		$shortcode = sprintf(
18
-			'[getpaid form=%s]',
19
-			(int) urldecode( $_GET['form'] )
20
-		);
21
-
22
-	} else {
23
-
24
-		$shortcode = sprintf(
25
-			'[getpaid item=%s]',
26
-			esc_attr( urldecode( $_GET['item'] ) )
27
-		);
28
-
29
-	}
3
+    // Is the request set up correctly?
4
+    if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) {
5
+        return aui()->alert(
6
+            array(
7
+                'type'    => 'warning',
8
+                'content' => __( 'No payment form or item selected', 'invoicing' ),
9
+            )
10
+        );
11
+        wp_die( __( 'No payment form or item selected', 'invoicing' ), 400 );
12
+    }
13
+
14
+    // Payment form or button?
15
+    if ( ! empty( $_GET['form'] ) ) {
16
+
17
+        $shortcode = sprintf(
18
+            '[getpaid form=%s]',
19
+            (int) urldecode( $_GET['form'] )
20
+        );
21
+
22
+    } else {
23
+
24
+        $shortcode = sprintf(
25
+            '[getpaid item=%s]',
26
+            esc_attr( urldecode( $_GET['item'] ) )
27
+        );
28
+
29
+    }
30 30
 
31 31
 ?>
32 32
 
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
 	<body class="body" style="font-weight: 400;">
54 54
 	<div class="container my-5" style="max-width: 820px;">
55 55
 			<?php
56
-				do_action( 'getpaid_payment_form_embed_top' );
57
-				echo do_shortcode( $shortcode );
58
-				do_action( 'getpaid_payment_form_embed_bottom' );
59
-				wpinv_get_template( 'frontend-footer.php' );
60
-			?>
56
+                do_action( 'getpaid_payment_form_embed_top' );
57
+                echo do_shortcode( $shortcode );
58
+                do_action( 'getpaid_payment_form_embed_bottom' );
59
+                wpinv_get_template( 'frontend-footer.php' );
60
+            ?>
61 61
 		</div>
62 62
 	</body>
63 63
 </html>
Please login to merge, or discard this patch.
includes/class-wpinv-ajax.php 1 patch
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -14,70 +14,70 @@  discard block
 block discarded – undo
14 14
 class WPInv_Ajax {
15 15
 
16 16
     /**
17
-	 * Hook in ajax handlers.
18
-	 */
19
-	public static function init() {
20
-		add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
21
-		add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 );
22
-		self::add_ajax_events();
17
+     * Hook in ajax handlers.
18
+     */
19
+    public static function init() {
20
+        add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
21
+        add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 );
22
+        self::add_ajax_events();
23 23
     }
24 24
 
25 25
     /**
26
-	 * Set GetPaid AJAX constant and headers.
27
-	 */
28
-	public static function define_ajax() {
29
-
30
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
31
-			getpaid_maybe_define_constant( 'DOING_AJAX', true );
32
-			getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true );
33
-			if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
34
-				/** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 );
35
-			}
36
-			$GLOBALS['wpdb']->hide_errors();
37
-		}
26
+     * Set GetPaid AJAX constant and headers.
27
+     */
28
+    public static function define_ajax() {
29
+
30
+        if ( ! empty( $_GET['wpinv-ajax'] ) ) {
31
+            getpaid_maybe_define_constant( 'DOING_AJAX', true );
32
+            getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true );
33
+            if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
34
+                /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 );
35
+            }
36
+            $GLOBALS['wpdb']->hide_errors();
37
+        }
38 38
 
39 39
     }
40 40
     
41 41
     /**
42
-	 * Send headers for GetPaid Ajax Requests.
43
-	 *
44
-	 * @since 1.0.18
45
-	 */
46
-	private static function wpinv_ajax_headers() {
47
-		if ( ! headers_sent() ) {
48
-			send_origin_headers();
49
-			send_nosniff_header();
50
-			nocache_headers();
51
-			header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
52
-			header( 'X-Robots-Tag: noindex' );
53
-			status_header( 200 );
54
-		}
42
+     * Send headers for GetPaid Ajax Requests.
43
+     *
44
+     * @since 1.0.18
45
+     */
46
+    private static function wpinv_ajax_headers() {
47
+        if ( ! headers_sent() ) {
48
+            send_origin_headers();
49
+            send_nosniff_header();
50
+            nocache_headers();
51
+            header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
52
+            header( 'X-Robots-Tag: noindex' );
53
+            status_header( 200 );
54
+        }
55 55
     }
56 56
     
57 57
     /**
58
-	 * Check for GetPaid Ajax request and fire action.
59
-	 */
60
-	public static function do_wpinv_ajax() {
61
-		global $wp_query;
58
+     * Check for GetPaid Ajax request and fire action.
59
+     */
60
+    public static function do_wpinv_ajax() {
61
+        global $wp_query;
62 62
 
63
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
64
-			$wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) );
65
-		}
63
+        if ( ! empty( $_GET['wpinv-ajax'] ) ) {
64
+            $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) );
65
+        }
66 66
 
67
-		$action = $wp_query->get( 'wpinv-ajax' );
67
+        $action = $wp_query->get( 'wpinv-ajax' );
68 68
 
69
-		if ( $action ) {
70
-			self::wpinv_ajax_headers();
71
-			$action = sanitize_text_field( $action );
72
-			do_action( 'wpinv_ajax_' . $action );
73
-			wp_die();
74
-		}
69
+        if ( $action ) {
70
+            self::wpinv_ajax_headers();
71
+            $action = sanitize_text_field( $action );
72
+            do_action( 'wpinv_ajax_' . $action );
73
+            wp_die();
74
+        }
75 75
 
76 76
     }
77 77
 
78 78
     /**
79
-	 * Hook in ajax methods.
80
-	 */
79
+     * Hook in ajax methods.
80
+     */
81 81
     public static function add_ajax_events() {
82 82
 
83 83
         // array( 'event' => is_frontend )
@@ -261,18 +261,18 @@  discard block
 block discarded – undo
261 261
         check_ajax_referer( 'getpaid_form_nonce' );
262 262
 
263 263
         // Is the request set up correctly?
264
-		if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) && empty( $_GET['invoice'] ) ) {
265
-			echo aui()->alert(
266
-				array(
267
-					'type'    => 'warning',
268
-					'content' => __( 'No payment form or item provided', 'invoicing' ),
269
-				)
264
+        if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) && empty( $_GET['invoice'] ) ) {
265
+            echo aui()->alert(
266
+                array(
267
+                    'type'    => 'warning',
268
+                    'content' => __( 'No payment form or item provided', 'invoicing' ),
269
+                )
270 270
             );
271 271
             exit;
272 272
         }
273 273
 
274 274
         // Payment form or button?
275
-		if ( ! empty( $_GET['form'] ) ) {
275
+        if ( ! empty( $_GET['form'] ) ) {
276 276
             $form = urldecode( $_GET['form'] );
277 277
 
278 278
             if ( false !== strpos( $form, '|' ) ) {
@@ -326,11 +326,11 @@  discard block
 block discarded – undo
326 326
                 getpaid_display_payment_form( $form );
327 327
             }
328 328
 
329
-		} else if( ! empty( $_GET['invoice'] ) ) {
330
-		    getpaid_display_invoice_payment_form( urldecode( $_GET['invoice'] ) );
329
+        } else if( ! empty( $_GET['invoice'] ) ) {
330
+            getpaid_display_invoice_payment_form( urldecode( $_GET['invoice'] ) );
331 331
         } else {
332
-			$items = getpaid_convert_items_to_array( urldecode( $_GET['item'] ) );
333
-		    getpaid_display_item_payment_form( $items );
332
+            $items = getpaid_convert_items_to_array( urldecode( $_GET['item'] ) );
333
+            getpaid_display_item_payment_form( $items );
334 334
         }
335 335
 
336 336
         exit;
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
         if ( is_wp_error( $error ) ) {
652 652
             $alert = $error->get_error_message();
653 653
             wp_send_json_success( compact( 'alert' ) );
654
-         }
654
+            }
655 655
 
656 656
         // Update totals.
657 657
         $invoice->recalculate_total();
@@ -1085,12 +1085,12 @@  discard block
 block discarded – undo
1085 1085
     }
1086 1086
 
1087 1087
     /**
1088
-	 * Handles file uploads.
1089
-	 *
1090
-	 * @since       1.0.0
1091
-	 * @return      void
1092
-	 */
1093
-	public static function file_upload() {
1088
+     * Handles file uploads.
1089
+     *
1090
+     * @since       1.0.0
1091
+     * @return      void
1092
+     */
1093
+    public static function file_upload() {
1094 1094
 
1095 1095
         // Check nonce.
1096 1096
         check_ajax_referer( 'getpaid_form_nonce' );
@@ -1151,7 +1151,7 @@  discard block
 block discarded – undo
1151 1151
 
1152 1152
         wp_send_json_success( $response );
1153 1153
 
1154
-	}
1154
+    }
1155 1155
 
1156 1156
 }
1157 1157
 
Please login to merge, or discard this patch.
includes/payments/class-getpaid-checkout.php 1 patch
Indentation   +297 added lines, -297 removed lines patch added patch discarded remove patch
@@ -12,180 +12,180 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Checkout {
14 14
 
15
-	/**
16
-	 * @var GetPaid_Payment_Form_Submission
17
-	 */
18
-	protected $payment_form_submission;
19
-
20
-	/**
21
-	 * Class constructor.
22
-	 * 
23
-	 * @param GetPaid_Payment_Form_Submission $submission
24
-	 */
25
-	public function __construct( $submission ) {
26
-		$this->payment_form_submission = $submission;
27
-	}
28
-
29
-	/**
30
-	 * Processes the checkout.
31
-	 *
32
-	 */
33
-	public function process_checkout() {
34
-
35
-		// Validate the submission.
36
-		$this->validate_submission();
37
-
38
-		// Prepare the invoice.
39
-		$items      = $this->get_submission_items();
40
-		$invoice    = $this->get_submission_invoice();
41
-		$invoice    = $this->process_submission_invoice( $invoice, $items );
42
-		$prepared   = $this->prepare_submission_data_for_saving();
43
-
44
-		$this->prepare_billing_info( $invoice );
45
-
46
-		$shipping   = $this->prepare_shipping_info( $invoice );
47
-
48
-		// Save the invoice.
49
-		$invoice->set_is_viewed( true );
50
-		$invoice->recalculate_total();
15
+    /**
16
+     * @var GetPaid_Payment_Form_Submission
17
+     */
18
+    protected $payment_form_submission;
19
+
20
+    /**
21
+     * Class constructor.
22
+     * 
23
+     * @param GetPaid_Payment_Form_Submission $submission
24
+     */
25
+    public function __construct( $submission ) {
26
+        $this->payment_form_submission = $submission;
27
+    }
28
+
29
+    /**
30
+     * Processes the checkout.
31
+     *
32
+     */
33
+    public function process_checkout() {
34
+
35
+        // Validate the submission.
36
+        $this->validate_submission();
37
+
38
+        // Prepare the invoice.
39
+        $items      = $this->get_submission_items();
40
+        $invoice    = $this->get_submission_invoice();
41
+        $invoice    = $this->process_submission_invoice( $invoice, $items );
42
+        $prepared   = $this->prepare_submission_data_for_saving();
43
+
44
+        $this->prepare_billing_info( $invoice );
45
+
46
+        $shipping   = $this->prepare_shipping_info( $invoice );
47
+
48
+        // Save the invoice.
49
+        $invoice->set_is_viewed( true );
50
+        $invoice->recalculate_total();
51 51
         $invoice->save();
52 52
 
53
-		do_action( 'getpaid_checkout_invoice_updated', $invoice );
53
+        do_action( 'getpaid_checkout_invoice_updated', $invoice );
54 54
 
55
-		// Send to the gateway.
56
-		$this->post_process_submission( $invoice, $prepared, $shipping );
57
-	}
55
+        // Send to the gateway.
56
+        $this->post_process_submission( $invoice, $prepared, $shipping );
57
+    }
58 58
 
59
-	/**
60
-	 * Validates the submission.
61
-	 *
62
-	 */
63
-	protected function validate_submission() {
59
+    /**
60
+     * Validates the submission.
61
+     *
62
+     */
63
+    protected function validate_submission() {
64 64
 
65
-		$submission = $this->payment_form_submission;
66
-		$data       = $submission->get_data();
65
+        $submission = $this->payment_form_submission;
66
+        $data       = $submission->get_data();
67 67
 
68
-		// Do we have an error?
68
+        // Do we have an error?
69 69
         if ( ! empty( $submission->last_error ) ) {
70
-			wp_send_json_error( $submission->last_error );
70
+            wp_send_json_error( $submission->last_error );
71 71
         }
72 72
 
73
-		// We need a billing email.
73
+        // We need a billing email.
74 74
         if ( ! $submission->has_billing_email() ) {
75 75
             wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) );
76
-		}
76
+        }
77 77
 
78
-		// Non-recurring gateways should not be allowed to process recurring invoices.
79
-		if ( $submission->should_collect_payment_details() && $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) {
80
-			wp_send_json_error( __( 'The selected payment gateway does not support subscription payments.', 'invoicing' ) );
81
-		}
78
+        // Non-recurring gateways should not be allowed to process recurring invoices.
79
+        if ( $submission->should_collect_payment_details() && $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) {
80
+            wp_send_json_error( __( 'The selected payment gateway does not support subscription payments.', 'invoicing' ) );
81
+        }
82 82
 
83
-		// Ensure the gateway is active.
84
-		if ( $submission->should_collect_payment_details() && ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) {
85
-			wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not active', 'invoicing' ) );
86
-		}
83
+        // Ensure the gateway is active.
84
+        if ( $submission->should_collect_payment_details() && ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) {
85
+            wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not active', 'invoicing' ) );
86
+        }
87 87
 
88
-		// Clear any existing errors.
89
-		wpinv_clear_errors();
88
+        // Clear any existing errors.
89
+        wpinv_clear_errors();
90 90
 
91
-		// Allow themes and plugins to hook to errors
92
-		do_action( 'getpaid_checkout_error_checks', $submission );
91
+        // Allow themes and plugins to hook to errors
92
+        do_action( 'getpaid_checkout_error_checks', $submission );
93 93
 
94
-		// Do we have any errors?
94
+        // Do we have any errors?
95 95
         if ( wpinv_get_errors() ) {
96 96
             wp_send_json_error( getpaid_get_errors_html() );
97
-		}
97
+        }
98 98
 
99
-	}
99
+    }
100 100
 
101
-	/**
102
-	 * Retrieves submission items.
103
-	 *
104
-	 * @return GetPaid_Form_Item[]
105
-	 */
106
-	protected function get_submission_items() {
101
+    /**
102
+     * Retrieves submission items.
103
+     *
104
+     * @return GetPaid_Form_Item[]
105
+     */
106
+    protected function get_submission_items() {
107 107
 
108
-		$items = $this->payment_form_submission->get_items();
108
+        $items = $this->payment_form_submission->get_items();
109 109
 
110 110
         // Ensure that we have items.
111 111
         if ( empty( $items ) && ! $this->payment_form_submission->has_fees() ) {
112 112
             wp_send_json_error( __( 'Please provide at least one item or amount.', 'invoicing' ) );
113
-		}
114
-
115
-		return $items;
116
-	}
117
-
118
-	/**
119
-	 * Retrieves submission invoice.
120
-	 *
121
-	 * @return WPInv_Invoice
122
-	 */
123
-	protected function get_submission_invoice() {
124
-		$submission = $this->payment_form_submission;
125
-
126
-		if ( ! $submission->has_invoice() ) {
127
-			$invoice = new WPInv_Invoice();
128
-			$invoice->set_created_via( 'payment_form' );
129
-			return $invoice;
130 113
         }
131 114
 
132
-		$invoice = $submission->get_invoice();
115
+        return $items;
116
+    }
117
+
118
+    /**
119
+     * Retrieves submission invoice.
120
+     *
121
+     * @return WPInv_Invoice
122
+     */
123
+    protected function get_submission_invoice() {
124
+        $submission = $this->payment_form_submission;
125
+
126
+        if ( ! $submission->has_invoice() ) {
127
+            $invoice = new WPInv_Invoice();
128
+            $invoice->set_created_via( 'payment_form' );
129
+            return $invoice;
130
+        }
131
+
132
+        $invoice = $submission->get_invoice();
133 133
 
134
-		// Make sure that it is neither paid or refunded.
135
-		if ( $invoice->is_paid() || $invoice->is_refunded() ) {
136
-			wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) );
137
-		}
134
+        // Make sure that it is neither paid or refunded.
135
+        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
136
+            wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) );
137
+        }
138 138
 
139
-		return $invoice;
140
-	}
139
+        return $invoice;
140
+    }
141 141
 
142
-	/**
143
-	 * Processes the submission invoice.
144
-	 *
145
-	 * @param WPInv_Invoice $invoice
146
-	 * @param GetPaid_Form_Item[] $items
147
-	 * @return WPInv_Invoice
148
-	 */
149
-	protected function process_submission_invoice( $invoice, $items ) {
142
+    /**
143
+     * Processes the submission invoice.
144
+     *
145
+     * @param WPInv_Invoice $invoice
146
+     * @param GetPaid_Form_Item[] $items
147
+     * @return WPInv_Invoice
148
+     */
149
+    protected function process_submission_invoice( $invoice, $items ) {
150 150
 
151
-		$submission = $this->payment_form_submission;
151
+        $submission = $this->payment_form_submission;
152 152
 
153
-		// Set-up the invoice details.
154
-		$invoice->set_email( sanitize_email( $submission->get_billing_email() ) );
155
-		$invoice->set_user_id( $this->get_submission_customer() );
156
-		$invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) );
153
+        // Set-up the invoice details.
154
+        $invoice->set_email( sanitize_email( $submission->get_billing_email() ) );
155
+        $invoice->set_user_id( $this->get_submission_customer() );
156
+        $invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) );
157 157
         $invoice->set_items( $items );
158 158
         $invoice->set_fees( $submission->get_fees() );
159 159
         $invoice->set_taxes( $submission->get_taxes() );
160
-		$invoice->set_discounts( $submission->get_discounts() );
161
-		$invoice->set_gateway( $submission->get_field( 'wpi-gateway' ) );
162
-		$invoice->set_currency( $submission->get_currency() );
160
+        $invoice->set_discounts( $submission->get_discounts() );
161
+        $invoice->set_gateway( $submission->get_field( 'wpi-gateway' ) );
162
+        $invoice->set_currency( $submission->get_currency() );
163 163
 
164
-		$address_confirmed = $submission->get_field( 'confirm-address' );
165
-		$invoice->set_address_confirmed( ! empty( $address_confirmed ) );
164
+        $address_confirmed = $submission->get_field( 'confirm-address' );
165
+        $invoice->set_address_confirmed( ! empty( $address_confirmed ) );
166 166
 
167
-		if ( $submission->has_discount_code() ) {
167
+        if ( $submission->has_discount_code() ) {
168 168
             $invoice->set_discount_code( $submission->get_discount_code() );
169
-		}
170
-
171
-		getpaid_maybe_add_default_address( $invoice );
172
-		return $invoice;
173
-	}
174
-
175
-	/**
176
-	 * Retrieves the submission's customer.
177
-	 *
178
-	 * @return int The customer id.
179
-	 */
180
-	protected function get_submission_customer() {
181
-		$submission = $this->payment_form_submission;
182
-
183
-		// If this is an existing invoice...
184
-		if ( $submission->has_invoice() ) {
185
-			return $submission->get_invoice()->get_user_id();
186
-		}
187
-
188
-		// (Maybe) create the user.
169
+        }
170
+
171
+        getpaid_maybe_add_default_address( $invoice );
172
+        return $invoice;
173
+    }
174
+
175
+    /**
176
+     * Retrieves the submission's customer.
177
+     *
178
+     * @return int The customer id.
179
+     */
180
+    protected function get_submission_customer() {
181
+        $submission = $this->payment_form_submission;
182
+
183
+        // If this is an existing invoice...
184
+        if ( $submission->has_invoice() ) {
185
+            return $submission->get_invoice()->get_user_id();
186
+        }
187
+
188
+        // (Maybe) create the user.
189 189
         $user = get_current_user_id();
190 190
 
191 191
         if ( empty( $user ) ) {
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
         if ( empty( $user ) ) {
196 196
             $user = wpinv_create_user( $submission->get_billing_email() );
197 197
 
198
-			// (Maybe) send new user notification.
199
-			$should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
200
-			if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ), $user ) ) {
201
-				wp_send_new_user_notifications( $user, 'user' );
202
-			}
198
+            // (Maybe) send new user notification.
199
+            $should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
200
+            if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ), $user ) ) {
201
+                wp_send_new_user_notifications( $user, 'user' );
202
+            }
203 203
 
204 204
         }
205 205
 
@@ -209,49 +209,49 @@  discard block
 block discarded – undo
209 209
 
210 210
         if ( is_numeric( $user ) ) {
211 211
             return $user;
212
-		}
212
+        }
213 213
 
214
-		return $user->ID;
214
+        return $user->ID;
215 215
 
216
-	}
216
+    }
217 217
 
218
-	/**
218
+    /**
219 219
      * Prepares submission data for saving to the database.
220 220
      *
221
-	 * @return array
221
+     * @return array
222 222
      */
223 223
     public function prepare_submission_data_for_saving() {
224 224
 
225
-		$submission = $this->payment_form_submission;
225
+        $submission = $this->payment_form_submission;
226 226
 
227
-		// Prepared submission details.
227
+        // Prepared submission details.
228 228
         $prepared = array(
229
-			'all'  => array(),
230
-			'meta' => array(),
231
-		);
229
+            'all'  => array(),
230
+            'meta' => array(),
231
+        );
232 232
 
233 233
         // Raw submission details.
234
-		$data     = $submission->get_data();
234
+        $data     = $submission->get_data();
235 235
 
236
-		// Loop through the submitted details.
236
+        // Loop through the submitted details.
237 237
         foreach ( $submission->get_payment_form()->get_elements() as $field ) {
238 238
 
239
-			// Skip premade fields.
239
+            // Skip premade fields.
240 240
             if ( ! empty( $field['premade'] ) ) {
241 241
                 continue;
242 242
             }
243 243
 
244
-			// Ensure address is provided.
245
-			if ( $field['type'] == 'address' ) {
244
+            // Ensure address is provided.
245
+            if ( $field['type'] == 'address' ) {
246 246
                 $address_type = 'shipping' === $field['address_type'] ? 'shipping' : 'billing';
247 247
 
248
-				foreach ( $field['fields'] as $address_field ) {
248
+                foreach ( $field['fields'] as $address_field ) {
249 249
 
250
-					if ( ! empty( $address_field['visible'] ) && ! empty( $address_field['required'] ) && '' === trim( $_POST[ $address_type ][ $address_field['name'] ] ) ) {
251
-						wp_send_json_error( __( 'Please fill all required fields.', 'invoicing' ) );
252
-					}
250
+                    if ( ! empty( $address_field['visible'] ) && ! empty( $address_field['required'] ) && '' === trim( $_POST[ $address_type ][ $address_field['name'] ] ) ) {
251
+                        wp_send_json_error( __( 'Please fill all required fields.', 'invoicing' ) );
252
+                    }
253 253
 
254
-				}
254
+                }
255 255
 
256 256
             }
257 257
 
@@ -263,31 +263,31 @@  discard block
 block discarded – undo
263 263
             // Handle misc fields.
264 264
             if ( isset( $data[ $field['id'] ] ) ) {
265 265
 
266
-				// Uploads.
267
-				if ( $field['type'] == 'file_upload' ) {
268
-					$max_file_num = empty( $field['max_file_num'] ) ? 1 : absint( $field['max_file_num'] );
266
+                // Uploads.
267
+                if ( $field['type'] == 'file_upload' ) {
268
+                    $max_file_num = empty( $field['max_file_num'] ) ? 1 : absint( $field['max_file_num'] );
269 269
 
270
-					if ( count( $data[ $field['id'] ] ) > $max_file_num ) {
271
-						wp_send_json_error( __( 'Maximum number of allowed files exceeded.', 'invoicing' ) );
272
-					}
270
+                    if ( count( $data[ $field['id'] ] ) > $max_file_num ) {
271
+                        wp_send_json_error( __( 'Maximum number of allowed files exceeded.', 'invoicing' ) );
272
+                    }
273 273
 
274
-					$value = array();
274
+                    $value = array();
275 275
 
276
-					foreach ( $data[ $field['id'] ] as $url => $name ) {
277
-						$value[] = sprintf(
278
-							'<a href="%s" target="_blank">%s</a>',
279
-							esc_url_raw( $url ),
280
-							esc_html( $name )
281
-						);
282
-					}
276
+                    foreach ( $data[ $field['id'] ] as $url => $name ) {
277
+                        $value[] = sprintf(
278
+                            '<a href="%s" target="_blank">%s</a>',
279
+                            esc_url_raw( $url ),
280
+                            esc_html( $name )
281
+                        );
282
+                    }
283 283
 
284
-					$value = implode( ' | ', $value );
284
+                    $value = implode( ' | ', $value );
285 285
 
286
-				} else if ( $field['type'] == 'checkbox' ) {
287
-					$value = isset( $data[ $field['id'] ] ) ? __( 'Yes', 'invoicing' ) : __( 'No', 'invoicing' );
288
-				} else {
289
-					$value = wp_kses_post( $data[ $field['id'] ] );
290
-				}
286
+                } else if ( $field['type'] == 'checkbox' ) {
287
+                    $value = isset( $data[ $field['id'] ] ) ? __( 'Yes', 'invoicing' ) : __( 'No', 'invoicing' );
288
+                } else {
289
+                    $value = wp_kses_post( $data[ $field['id'] ] );
290
+                }
291 291
 
292 292
                 $label = $field['id'];
293 293
 
@@ -295,189 +295,189 @@  discard block
 block discarded – undo
295 295
                     $label = $field['label'];
296 296
                 }
297 297
 
298
-				if ( ! empty( $field['add_meta'] ) ) {
299
-					$prepared['meta'][ wpinv_clean( $label ) ] = wp_kses_post_deep( $value );
300
-				}
301
-				$prepared['all'][ wpinv_clean( $label ) ] = wp_kses_post_deep( $value );
298
+                if ( ! empty( $field['add_meta'] ) ) {
299
+                    $prepared['meta'][ wpinv_clean( $label ) ] = wp_kses_post_deep( $value );
300
+                }
301
+                $prepared['all'][ wpinv_clean( $label ) ] = wp_kses_post_deep( $value );
302 302
 
303 303
             }
304 304
 
305
-		}
305
+        }
306 306
 
307
-		return $prepared;
307
+        return $prepared;
308 308
 
309
-	}
309
+    }
310 310
 
311
-	/**
311
+    /**
312 312
      * Retrieves address details.
313 313
      *
314
-	 * @return array
315
-	 * @param WPInv_Invoice $invoice
316
-	 * @param string $type
314
+     * @return array
315
+     * @param WPInv_Invoice $invoice
316
+     * @param string $type
317 317
      */
318 318
     public function prepare_address_details( $invoice, $type = 'billing' ) {
319 319
 
320
-		$data     = $this->payment_form_submission->get_data();
321
-		$type     = sanitize_key( $type );
322
-		$address  = array();
323
-		$prepared = array();
320
+        $data     = $this->payment_form_submission->get_data();
321
+        $type     = sanitize_key( $type );
322
+        $address  = array();
323
+        $prepared = array();
324 324
 
325
-		if ( ! empty( $data[ $type ] ) ) {
326
-			$address = $data[ $type ];
327
-		}
325
+        if ( ! empty( $data[ $type ] ) ) {
326
+            $address = $data[ $type ];
327
+        }
328 328
 
329
-		// Clean address details.
330
-		foreach ( $address as $key => $value ) {
331
-			$key             = sanitize_key( $key );
332
-			$key             = str_replace( 'wpinv_', '', $key );
333
-			$value           = wpinv_clean( $value );
334
-			$prepared[ $key] = apply_filters( "getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice );
335
-		}
329
+        // Clean address details.
330
+        foreach ( $address as $key => $value ) {
331
+            $key             = sanitize_key( $key );
332
+            $key             = str_replace( 'wpinv_', '', $key );
333
+            $value           = wpinv_clean( $value );
334
+            $prepared[ $key] = apply_filters( "getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice );
335
+        }
336 336
 
337
-		// Filter address details.
338
-		$prepared = apply_filters( "getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice );
337
+        // Filter address details.
338
+        $prepared = apply_filters( "getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice );
339 339
 
340
-		// Remove non-whitelisted values.
341
-		return array_filter( $prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY );
340
+        // Remove non-whitelisted values.
341
+        return array_filter( $prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY );
342 342
 
343
-	}
343
+    }
344 344
 
345
-	/**
345
+    /**
346 346
      * Prepares the billing details.
347 347
      *
348
-	 * @return array
349
-	 * @param WPInv_Invoice $invoice
348
+     * @return array
349
+     * @param WPInv_Invoice $invoice
350 350
      */
351 351
     protected function prepare_billing_info( &$invoice ) {
352 352
 
353
-		$billing_address = $this->prepare_address_details( $invoice, 'billing' );
353
+        $billing_address = $this->prepare_address_details( $invoice, 'billing' );
354 354
 
355
-		// Update the invoice with the billing details.
356
-		$invoice->set_props( $billing_address );
355
+        // Update the invoice with the billing details.
356
+        $invoice->set_props( $billing_address );
357 357
 
358
-	}
358
+    }
359 359
 
360
-	/**
360
+    /**
361 361
      * Prepares the shipping details.
362 362
      *
363
-	 * @return array
364
-	 * @param WPInv_Invoice $invoice
363
+     * @return array
364
+     * @param WPInv_Invoice $invoice
365 365
      */
366 366
     protected function prepare_shipping_info( $invoice ) {
367 367
 
368
-		$data = $this->payment_form_submission->get_data();
368
+        $data = $this->payment_form_submission->get_data();
369 369
 
370
-		if ( empty( $data['same-shipping-address'] ) ) {
371
-			return $this->prepare_address_details( $invoice, 'shipping' );
372
-		}
370
+        if ( empty( $data['same-shipping-address'] ) ) {
371
+            return $this->prepare_address_details( $invoice, 'shipping' );
372
+        }
373 373
 
374
-		return $this->prepare_address_details( $invoice, 'billing' );
374
+        return $this->prepare_address_details( $invoice, 'billing' );
375 375
 
376
-	}
376
+    }
377 377
 
378
-	/**
379
-	 * Confirms the submission is valid and send users to the gateway.
380
-	 *
381
-	 * @param WPInv_Invoice $invoice
382
-	 * @param array $prepared_payment_form_data
383
-	 * @param array $shipping
384
-	 */
385
-	protected function post_process_submission( $invoice, $prepared_payment_form_data, $shipping ) {
378
+    /**
379
+     * Confirms the submission is valid and send users to the gateway.
380
+     *
381
+     * @param WPInv_Invoice $invoice
382
+     * @param array $prepared_payment_form_data
383
+     * @param array $shipping
384
+     */
385
+    protected function post_process_submission( $invoice, $prepared_payment_form_data, $shipping ) {
386 386
 
387
-		// Ensure the invoice exists.
387
+        // Ensure the invoice exists.
388 388
         if ( ! $invoice->exists() ) {
389 389
             wp_send_json_error( __( 'An error occured while saving your invoice. Please try again.', 'invoicing' ) );
390 390
         }
391 391
 
392
-		// Save payment form data.
393
-		$prepared_payment_form_data = apply_filters( 'getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice );
392
+        // Save payment form data.
393
+        $prepared_payment_form_data = apply_filters( 'getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice );
394 394
         delete_post_meta( $invoice->get_id(), 'payment_form_data' );
395
-		delete_post_meta( $invoice->get_id(), 'additional_meta_data' );
396
-		if ( ! empty( $prepared_payment_form_data ) ) {
395
+        delete_post_meta( $invoice->get_id(), 'additional_meta_data' );
396
+        if ( ! empty( $prepared_payment_form_data ) ) {
397 397
 
398
-			if ( ! empty( $prepared_payment_form_data['all'] ) ) {
399
-				update_post_meta( $invoice->get_id(), 'payment_form_data', $prepared_payment_form_data['all'] );
400
-			}
398
+            if ( ! empty( $prepared_payment_form_data['all'] ) ) {
399
+                update_post_meta( $invoice->get_id(), 'payment_form_data', $prepared_payment_form_data['all'] );
400
+            }
401 401
 
402
-			if ( ! empty( $prepared_payment_form_data['meta'] ) ) {
403
-				update_post_meta( $invoice->get_id(), 'additional_meta_data', $prepared_payment_form_data['meta'] );
404
-			}
402
+            if ( ! empty( $prepared_payment_form_data['meta'] ) ) {
403
+                update_post_meta( $invoice->get_id(), 'additional_meta_data', $prepared_payment_form_data['meta'] );
404
+            }
405 405
 
406
-		}
406
+        }
407 407
 
408
-		// Save payment form data.
408
+        // Save payment form data.
409 409
         if ( ! empty( $shipping ) ) {
410 410
             update_post_meta( $invoice->get_id(), 'shipping_address', $shipping );
411
-		}
411
+        }
412 412
 
413
-		// Backwards compatibility.
413
+        // Backwards compatibility.
414 414
         add_filter( 'wp_redirect', array( $this, 'send_redirect_response' ) );
415 415
 
416
-		$this->process_payment( $invoice );
416
+        $this->process_payment( $invoice );
417 417
 
418 418
         // If we are here, there was an error.
419
-		wpinv_send_back_to_checkout( $invoice );
419
+        wpinv_send_back_to_checkout( $invoice );
420 420
 
421
-	}
421
+    }
422 422
 
423
-	/**
424
-	 * Processes the actual payment.
425
-	 *
426
-	 * @param WPInv_Invoice $invoice
427
-	 */
428
-	protected function process_payment( $invoice ) {
423
+    /**
424
+     * Processes the actual payment.
425
+     *
426
+     * @param WPInv_Invoice $invoice
427
+     */
428
+    protected function process_payment( $invoice ) {
429 429
 
430
-		// Clear any checkout errors.
431
-		wpinv_clear_errors();
430
+        // Clear any checkout errors.
431
+        wpinv_clear_errors();
432 432
 
433
-		// No need to send free invoices to the gateway.
434
-		if ( $invoice->is_free() ) {
435
-			$this->process_free_payment( $invoice );
436
-		}
433
+        // No need to send free invoices to the gateway.
434
+        if ( $invoice->is_free() ) {
435
+            $this->process_free_payment( $invoice );
436
+        }
437 437
 
438
-		$submission = $this->payment_form_submission;
438
+        $submission = $this->payment_form_submission;
439 439
 
440
-		// Fires before sending to the gateway.
441
-		do_action( 'getpaid_checkout_before_gateway', $invoice, $submission );
440
+        // Fires before sending to the gateway.
441
+        do_action( 'getpaid_checkout_before_gateway', $invoice, $submission );
442 442
 
443
-		// Allow the sumission data to be modified before it is sent to the gateway.
444
-		$submission_data    = $submission->get_data();
445
-		$submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice );
446
-		$submission_data    = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice );
443
+        // Allow the sumission data to be modified before it is sent to the gateway.
444
+        $submission_data    = $submission->get_data();
445
+        $submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice );
446
+        $submission_data    = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice );
447 447
 
448
-		// Validate the currency.
449
-		if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) {
450
-			wpinv_set_error( 'invalid_currency', __( 'The chosen payment gateway does not support this currency', 'invoicing' ) );
451
-		}
448
+        // Validate the currency.
449
+        if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) {
450
+            wpinv_set_error( 'invalid_currency', __( 'The chosen payment gateway does not support this currency', 'invoicing' ) );
451
+        }
452 452
 
453
-		// Check to see if we have any errors.
454
-		if ( wpinv_get_errors() ) {
455
-			wpinv_send_back_to_checkout( $invoice );
456
-		}
453
+        // Check to see if we have any errors.
454
+        if ( wpinv_get_errors() ) {
455
+            wpinv_send_back_to_checkout( $invoice );
456
+        }
457 457
 
458
-		// Send info to the gateway for payment processing
459
-		do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission );
458
+        // Send info to the gateway for payment processing
459
+        do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission );
460 460
 
461
-		// Backwards compatibility.
462
-		wpinv_send_to_gateway( $submission_gateway, $invoice );
461
+        // Backwards compatibility.
462
+        wpinv_send_to_gateway( $submission_gateway, $invoice );
463 463
 
464
-	}
464
+    }
465 465
 
466
-	/**
467
-	 * Marks the invoice as paid in case the checkout is free.
468
-	 *
469
-	 * @param WPInv_Invoice $invoice
470
-	 */
471
-	protected function process_free_payment( $invoice ) {
466
+    /**
467
+     * Marks the invoice as paid in case the checkout is free.
468
+     *
469
+     * @param WPInv_Invoice $invoice
470
+     */
471
+    protected function process_free_payment( $invoice ) {
472 472
 
473
-		$invoice->set_gateway( 'none' );
474
-		$invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true );
475
-		$invoice->mark_paid();
476
-		wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
473
+        $invoice->set_gateway( 'none' );
474
+        $invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true );
475
+        $invoice->mark_paid();
476
+        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
477 477
 
478
-	}
478
+    }
479 479
 
480
-	/**
480
+    /**
481 481
      * Sends a redrect response to payment details.
482 482
      *
483 483
      */
Please login to merge, or discard this patch.
includes/wpinv-helper-functions.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -136,13 +136,13 @@  discard block
 block discarded – undo
136 136
  */
137 137
 function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
138 138
 
139
-	$invoice_statuses = array(
140
-		'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
139
+    $invoice_statuses = array(
140
+        'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
141 141
         'publish'        => _x( 'Paid', 'Invoice status', 'invoicing' ),
142 142
         'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ),
143
-		'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
144
-		'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
145
-		'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
143
+        'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
144
+        'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
145
+        'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
146 146
         'wpi-failed'     => _x( 'Failed', 'Invoice status', 'invoicing' ),
147 147
         'wpi-renewal'    => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ),
148 148
     );
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
         $invoice = $invoice->get_post_type();
160 160
     }
161 161
 
162
-	return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
162
+    return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
163 163
 }
164 164
 
165 165
 /**
@@ -277,25 +277,25 @@  discard block
 block discarded – undo
277 277
  * @return string
278 278
  */
279 279
 function getpaid_get_price_format() {
280
-	$currency_pos = wpinv_currency_position();
281
-	$format       = '%1$s%2$s';
282
-
283
-	switch ( $currency_pos ) {
284
-		case 'left':
285
-			$format = '%1$s%2$s';
286
-			break;
287
-		case 'right':
288
-			$format = '%2$s%1$s';
289
-			break;
290
-		case 'left_space':
291
-			$format = '%1$s&nbsp;%2$s';
292
-			break;
293
-		case 'right_space':
294
-			$format = '%2$s&nbsp;%1$s';
295
-			break;
296
-	}
297
-
298
-	return apply_filters( 'getpaid_price_format', $format, $currency_pos );
280
+    $currency_pos = wpinv_currency_position();
281
+    $format       = '%1$s%2$s';
282
+
283
+    switch ( $currency_pos ) {
284
+        case 'left':
285
+            $format = '%1$s%2$s';
286
+            break;
287
+        case 'right':
288
+            $format = '%2$s%1$s';
289
+            break;
290
+        case 'left_space':
291
+            $format = '%1$s&nbsp;%2$s';
292
+            break;
293
+        case 'right_space':
294
+            $format = '%2$s&nbsp;%1$s';
295
+            break;
296
+    }
297
+
298
+    return apply_filters( 'getpaid_price_format', $format, $currency_pos );
299 299
 }
300 300
 
301 301
 /**
@@ -390,13 +390,13 @@  discard block
 block discarded – undo
390 390
  * @param mixed  $value Value.
391 391
  */
392 392
 function getpaid_maybe_define_constant( $name, $value ) {
393
-	if ( ! defined( $name ) ) {
394
-		define( $name, $value );
395
-	}
393
+    if ( ! defined( $name ) ) {
394
+        define( $name, $value );
395
+    }
396 396
 }
397 397
 
398 398
 function wpinv_get_php_arg_separator_output() {
399
-	return ini_get( 'arg_separator.output' );
399
+    return ini_get( 'arg_separator.output' );
400 400
 }
401 401
 
402 402
 function wpinv_rgb_from_hex( $color ) {
@@ -751,11 +751,11 @@  discard block
 block discarded – undo
751 751
         $list = array();
752 752
     }
753 753
 
754
-	if ( ! is_array( $list ) ) {
755
-		return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
756
-	}
754
+    if ( ! is_array( $list ) ) {
755
+        return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
756
+    }
757 757
 
758
-	return $list;
758
+    return $list;
759 759
 }
760 760
 
761 761
 /**
@@ -775,9 +775,9 @@  discard block
 block discarded – undo
775 775
     }
776 776
 
777 777
     $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" );
778
-	wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
778
+    wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
779 779
 
780
-	return $data;
780
+    return $data;
781 781
 }
782 782
 
783 783
 /**
@@ -806,17 +806,17 @@  discard block
 block discarded – undo
806 806
  */
807 807
 function wpinv_clean( $var ) {
808 808
 
809
-	if ( is_array( $var ) ) {
810
-		return array_map( 'wpinv_clean', $var );
809
+    if ( is_array( $var ) ) {
810
+        return array_map( 'wpinv_clean', $var );
811 811
     }
812 812
 
813 813
     if ( is_object( $var ) ) {
814
-		$object_vars = get_object_vars( $var );
815
-		foreach ( $object_vars as $property_name => $property_value ) {
816
-			$var->$property_name = wpinv_clean( $property_value );
814
+        $object_vars = get_object_vars( $var );
815
+        foreach ( $object_vars as $property_name => $property_value ) {
816
+            $var->$property_name = wpinv_clean( $property_value );
817 817
         }
818 818
         return $var;
819
-	}
819
+    }
820 820
 
821 821
     return is_string( $var ) ? sanitize_text_field( stripslashes( $var ) ) : $var;
822 822
 }
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
  */
830 830
 function getpaid_convert_price_string_to_options( $str ) {
831 831
 
832
-	$raw_options = array_map( 'trim', explode( ',', $str ) );
832
+    $raw_options = array_map( 'trim', explode( ',', $str ) );
833 833
     $options     = array();
834 834
 
835 835
     foreach ( $raw_options as $option ) {
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
  * @return string
913 913
  */
914 914
 function getpaid_date_format() {
915
-	return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
915
+    return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
916 916
 }
917 917
 
918 918
 /**
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
  * @return string
922 922
  */
923 923
 function getpaid_time_format() {
924
-	return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
924
+    return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
925 925
 }
926 926
 
927 927
 /**
@@ -934,15 +934,15 @@  discard block
 block discarded – undo
934 934
 function getpaid_limit_length( $string, $limit ) {
935 935
     $str_limit = $limit - 3;
936 936
 
937
-	if ( function_exists( 'mb_strimwidth' ) ) {
938
-		if ( mb_strlen( $string ) > $limit ) {
939
-			$string = mb_strimwidth( $string, 0, $str_limit ) . '...';
940
-		}
941
-	} else {
942
-		if ( strlen( $string ) > $limit ) {
943
-			$string = substr( $string, 0, $str_limit ) . '...';
944
-		}
945
-	}
937
+    if ( function_exists( 'mb_strimwidth' ) ) {
938
+        if ( mb_strlen( $string ) > $limit ) {
939
+            $string = mb_strimwidth( $string, 0, $str_limit ) . '...';
940
+        }
941
+    } else {
942
+        if ( strlen( $string ) > $limit ) {
943
+            $string = substr( $string, 0, $str_limit ) . '...';
944
+        }
945
+    }
946 946
     return $string;
947 947
 
948 948
 }
@@ -1073,12 +1073,12 @@  discard block
 block discarded – undo
1073 1073
     $types = get_allowed_mime_types();
1074 1074
 
1075 1075
     if ( isset( $types['htm|html'] ) ) {
1076
-		unset( $types['htm|html'] );
1077
-	}
1076
+        unset( $types['htm|html'] );
1077
+    }
1078 1078
 
1079 1079
     if ( isset( $types['js'] ) ) {
1080
-		unset( $types['js'] );
1081
-	}
1080
+        unset( $types['js'] );
1081
+    }
1082 1082
 
1083 1083
     return $types;
1084 1084
 
Please login to merge, or discard this patch.