Passed
Push — master ( 941e4d...c8e476 )
by Brian
06:36
created
includes/payments/class-getpaid-checkout.php 1 patch
Spacing   +101 added lines, -101 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
  * Main Checkout Class.
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 * 
23 23
 	 * @param GetPaid_Payment_Form_Submission $submission
24 24
 	 */
25
-	public function __construct( $submission ) {
25
+	public function __construct($submission) {
26 26
 		$this->payment_form_submission = $submission;
27 27
 	}
28 28
 
@@ -38,22 +38,22 @@  discard block
 block discarded – undo
38 38
 		// Prepare the invoice.
39 39
 		$items      = $this->get_submission_items();
40 40
 		$invoice    = $this->get_submission_invoice();
41
-		$invoice    = $this->process_submission_invoice( $invoice, $items );
41
+		$invoice    = $this->process_submission_invoice($invoice, $items);
42 42
 		$prepared   = $this->prepare_submission_data_for_saving();
43 43
 
44
-		$this->prepare_billing_info( $invoice );
44
+		$this->prepare_billing_info($invoice);
45 45
 
46
-		$shipping   = $this->prepare_shipping_info( $invoice );
46
+		$shipping = $this->prepare_shipping_info($invoice);
47 47
 
48 48
 		// Save the invoice.
49
-		$invoice->set_is_viewed( true );
49
+		$invoice->set_is_viewed(true);
50 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 55
 		// Send to the gateway.
56
-		$this->post_process_submission( $invoice, $prepared, $shipping );
56
+		$this->post_process_submission($invoice, $prepared, $shipping);
57 57
 	}
58 58
 
59 59
 	/**
@@ -66,34 +66,34 @@  discard block
 block discarded – undo
66 66
 		$data       = $submission->get_data();
67 67
 
68 68
 		// Do we have an error?
69
-        if ( ! empty( $submission->last_error ) ) {
70
-			wp_send_json_error( $submission->last_error );
69
+        if (!empty($submission->last_error)) {
70
+			wp_send_json_error($submission->last_error);
71 71
         }
72 72
 
73 73
 		// We need a billing email.
74
-        if ( ! $submission->has_billing_email() ) {
75
-            wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) );
74
+        if (!$submission->has_billing_email()) {
75
+            wp_send_json_error(__('Provide a valid billing email.', 'invoicing'));
76 76
 		}
77 77
 
78 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' ) );
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 81
 		}
82 82
 
83 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' ) );
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 86
 		}
87 87
 
88 88
 		// Clear any existing errors.
89 89
 		wpinv_clear_errors();
90 90
 
91 91
 		// Allow themes and plugins to hook to errors
92
-		do_action( 'getpaid_checkout_error_checks', $submission );
92
+		do_action('getpaid_checkout_error_checks', $submission);
93 93
 
94 94
 		// Do we have any errors?
95
-        if ( wpinv_get_errors() ) {
96
-            wp_send_json_error( getpaid_get_errors_html() );
95
+        if (wpinv_get_errors()) {
96
+            wp_send_json_error(getpaid_get_errors_html());
97 97
 		}
98 98
 
99 99
 	}
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
 		$items = $this->payment_form_submission->get_items();
109 109
 
110 110
         // Ensure that we have items.
111
-        if ( empty( $items ) && ! $this->payment_form_submission->has_fees() ) {
112
-            wp_send_json_error( __( 'Please provide at least one item or amount.', 'invoicing' ) );
111
+        if (empty($items) && !$this->payment_form_submission->has_fees()) {
112
+            wp_send_json_error(__('Please provide at least one item or amount.', 'invoicing'));
113 113
 		}
114 114
 
115 115
 		return $items;
@@ -123,17 +123,17 @@  discard block
 block discarded – undo
123 123
 	protected function get_submission_invoice() {
124 124
 		$submission = $this->payment_form_submission;
125 125
 
126
-		if ( ! $submission->has_invoice() ) {
126
+		if (!$submission->has_invoice()) {
127 127
 			$invoice = new WPInv_Invoice();
128
-			$invoice->created_via( 'payment_form' );
128
+			$invoice->created_via('payment_form');
129 129
 			return $invoice;
130 130
         }
131 131
 
132 132
 		$invoice = $submission->get_invoice();
133 133
 
134 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' ) );
135
+		if ($invoice->is_paid() || $invoice->is_refunded()) {
136
+			wp_send_json_error(__('This invoice has already been paid for.', 'invoicing'));
137 137
 		}
138 138
 
139 139
 		return $invoice;
@@ -146,26 +146,26 @@  discard block
 block discarded – undo
146 146
 	 * @param GetPaid_Form_Item[] $items
147 147
 	 * @return WPInv_Invoice
148 148
 	 */
149
-	protected function process_submission_invoice( $invoice, $items ) {
149
+	protected function process_submission_invoice($invoice, $items) {
150 150
 
151 151
 		$submission = $this->payment_form_submission;
152 152
 		$data       = $submission->get_data();
153 153
 
154 154
 		// Set-up the invoice details.
155
-		$invoice->set_email( sanitize_email( $submission->get_billing_email() ) );
156
-		$invoice->set_user_id( $this->get_submission_customer() );
157
-		$invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) );
158
-        $invoice->set_items( $items );
159
-        $invoice->set_fees( $submission->get_fees() );
160
-        $invoice->set_taxes( $submission->get_taxes() );
161
-		$invoice->set_discounts( $submission->get_discounts() );
162
-		$invoice->set_gateway( $data['wpi-gateway'] );
163
-
164
-		if ( $submission->has_discount_code() ) {
165
-            $invoice->set_discount_code( $submission->get_discount_code() );
155
+		$invoice->set_email(sanitize_email($submission->get_billing_email()));
156
+		$invoice->set_user_id($this->get_submission_customer());
157
+		$invoice->set_payment_form(absint($submission->get_payment_form()->get_id()));
158
+        $invoice->set_items($items);
159
+        $invoice->set_fees($submission->get_fees());
160
+        $invoice->set_taxes($submission->get_taxes());
161
+		$invoice->set_discounts($submission->get_discounts());
162
+		$invoice->set_gateway($data['wpi-gateway']);
163
+
164
+		if ($submission->has_discount_code()) {
165
+            $invoice->set_discount_code($submission->get_discount_code());
166 166
 		}
167 167
 
168
-		getpaid_maybe_add_default_address( $invoice );
168
+		getpaid_maybe_add_default_address($invoice);
169 169
 		return $invoice;
170 170
 	}
171 171
 
@@ -178,26 +178,26 @@  discard block
 block discarded – undo
178 178
 		$submission = $this->payment_form_submission;
179 179
 
180 180
 		// If this is an existing invoice...
181
-		if ( $submission->has_invoice() ) {
181
+		if ($submission->has_invoice()) {
182 182
 			return $submission->get_invoice()->get_user_id();
183 183
 		}
184 184
 
185 185
 		// (Maybe) create the user.
186 186
         $user = get_current_user_id();
187 187
 
188
-        if ( empty( $user ) ) {
189
-            $user = get_user_by( 'email', $submission->get_billing_email() );
188
+        if (empty($user)) {
189
+            $user = get_user_by('email', $submission->get_billing_email());
190 190
         }
191 191
 
192
-        if ( empty( $user ) ) {
193
-            $user = wpinv_create_user( $submission->get_billing_email() );
192
+        if (empty($user)) {
193
+            $user = wpinv_create_user($submission->get_billing_email());
194 194
         }
195 195
 
196
-        if ( is_wp_error( $user ) ) {
197
-            wp_send_json_error( $user->get_error_message() );
196
+        if (is_wp_error($user)) {
197
+            wp_send_json_error($user->get_error_message());
198 198
         }
199 199
 
200
-        if ( is_numeric( $user ) ) {
200
+        if (is_numeric($user)) {
201 201
             return $user;
202 202
 		}
203 203
 
@@ -218,30 +218,30 @@  discard block
 block discarded – undo
218 218
         $prepared = array();
219 219
 
220 220
         // Raw submission details.
221
-		$data     = $submission->get_data();
221
+		$data = $submission->get_data();
222 222
 
223 223
 		// Loop through the submitted details.
224
-        foreach ( $submission->get_payment_form()->get_elements() as $field ) {
224
+        foreach ($submission->get_payment_form()->get_elements() as $field) {
225 225
 
226 226
 			// Skip premade fields.
227
-            if ( ! empty( $field['premade'] ) || $field['type'] == 'address' ) {
227
+            if (!empty($field['premade']) || $field['type'] == 'address') {
228 228
                 continue;
229 229
             }
230 230
 
231 231
             // If it is required and not set, abort.
232
-            if ( ! $submission->is_required_field_set( $field ) ) {
233
-                wp_send_json_error( __( 'Please fill all required fields.', 'invoicing' ) );
232
+            if (!$submission->is_required_field_set($field)) {
233
+                wp_send_json_error(__('Please fill all required fields.', 'invoicing'));
234 234
             }
235 235
 
236 236
             // Handle misc fields.
237
-            if ( isset( $data[ $field['id'] ] ) ) {
237
+            if (isset($data[$field['id']])) {
238 238
                 $label = $field['id'];
239 239
 
240
-                if ( isset( $field['label'] ) ) {
240
+                if (isset($field['label'])) {
241 241
                     $label = $field['label'];
242 242
                 }
243 243
 
244
-				$prepared[ wpinv_clean( $label ) ] = wp_kses_post( $data[ $field['id'] ] );
244
+				$prepared[wpinv_clean($label)] = wp_kses_post($data[$field['id']]);
245 245
 
246 246
             }
247 247
 
@@ -258,30 +258,30 @@  discard block
 block discarded – undo
258 258
 	 * @param WPInv_Invoice $invoice
259 259
 	 * @param string $type
260 260
      */
261
-    public function prepare_address_details( $invoice, $type = 'billing' ) {
261
+    public function prepare_address_details($invoice, $type = 'billing') {
262 262
 
263 263
 		$data     = $this->payment_form_submission->get_data();
264
-		$type     = sanitize_key( $type );
264
+		$type     = sanitize_key($type);
265 265
 		$address  = array();
266 266
 		$prepared = array();
267 267
 
268
-		if ( ! empty( $data[ $type ] ) ) {
269
-			$address = $data[ $type ];
268
+		if (!empty($data[$type])) {
269
+			$address = $data[$type];
270 270
 		}
271 271
 
272 272
 		// Clean address details.
273
-		foreach ( $address as $key => $value ) {
274
-			$key             = sanitize_key( $key );
275
-			$key             = str_replace( 'wpinv_', '', $key );
276
-			$value           = wpinv_clean( $value );
277
-			$prepared[ $key] = apply_filters( "getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice );
273
+		foreach ($address as $key => $value) {
274
+			$key             = sanitize_key($key);
275
+			$key             = str_replace('wpinv_', '', $key);
276
+			$value           = wpinv_clean($value);
277
+			$prepared[$key] = apply_filters("getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice);
278 278
 		}
279 279
 
280 280
 		// Filter address details.
281
-		$prepared = apply_filters( "getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice );
281
+		$prepared = apply_filters("getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice);
282 282
 
283 283
 		// Remove non-whitelisted values.
284
-		return array_filter( $prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY );
284
+		return array_filter($prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY);
285 285
 
286 286
 	}
287 287
 
@@ -291,12 +291,12 @@  discard block
 block discarded – undo
291 291
 	 * @return array
292 292
 	 * @param WPInv_Invoice $invoice
293 293
      */
294
-    protected function prepare_billing_info( &$invoice ) {
294
+    protected function prepare_billing_info(&$invoice) {
295 295
 
296
-		$billing_address = $this->prepare_address_details( $invoice, 'billing' );
296
+		$billing_address = $this->prepare_address_details($invoice, 'billing');
297 297
 
298 298
 		// Update the invoice with the billing details.
299
-		$invoice->set_props( $billing_address );
299
+		$invoice->set_props($billing_address);
300 300
 
301 301
 	}
302 302
 
@@ -306,15 +306,15 @@  discard block
 block discarded – undo
306 306
 	 * @return array
307 307
 	 * @param WPInv_Invoice $invoice
308 308
      */
309
-    protected function prepare_shipping_info( $invoice ) {
309
+    protected function prepare_shipping_info($invoice) {
310 310
 
311 311
 		$data = $this->payment_form_submission->get_data();
312 312
 
313
-		if ( empty( $data['same-shipping-address'] ) ) {
314
-			return $this->prepare_address_details( $invoice, 'shipping' );
313
+		if (empty($data['same-shipping-address'])) {
314
+			return $this->prepare_address_details($invoice, 'shipping');
315 315
 		}
316 316
 
317
-		return $this->prepare_address_details( $invoice, 'billing' );
317
+		return $this->prepare_address_details($invoice, 'billing');
318 318
 
319 319
 	}
320 320
 
@@ -325,30 +325,30 @@  discard block
 block discarded – undo
325 325
 	 * @param array $prepared_payment_form_data
326 326
 	 * @param array $shipping
327 327
 	 */
328
-	protected function post_process_submission( $invoice, $prepared_payment_form_data, $shipping ) {
328
+	protected function post_process_submission($invoice, $prepared_payment_form_data, $shipping) {
329 329
 
330 330
 		// Ensure the invoice exists.
331
-        if ( ! $invoice->exists() ) {
332
-            wp_send_json_error( __( 'An error occured while saving your invoice. Please try again.', 'invoicing' ) );
331
+        if (!$invoice->exists()) {
332
+            wp_send_json_error(__('An error occured while saving your invoice. Please try again.', 'invoicing'));
333 333
         }
334 334
 
335 335
         // Save payment form data.
336
-        if ( ! empty( $prepared_payment_form_data ) ) {
337
-            update_post_meta( $invoice->get_id(), 'payment_form_data', $prepared_payment_form_data );
336
+        if (!empty($prepared_payment_form_data)) {
337
+            update_post_meta($invoice->get_id(), 'payment_form_data', $prepared_payment_form_data);
338 338
 		}
339 339
 
340 340
 		// Save payment form data.
341
-        if ( ! empty( $shipping ) ) {
342
-            update_post_meta( $invoice->get_id(), 'shipping_address', $shipping );
341
+        if (!empty($shipping)) {
342
+            update_post_meta($invoice->get_id(), 'shipping_address', $shipping);
343 343
 		}
344 344
 
345 345
 		// Backwards compatibility.
346
-        add_filter( 'wp_redirect', array( $this, 'send_redirect_response' ) );
346
+        add_filter('wp_redirect', array($this, 'send_redirect_response'));
347 347
 
348
-		$this->process_payment( $invoice );
348
+		$this->process_payment($invoice);
349 349
 
350 350
         // If we are here, there was an error.
351
-		wpinv_send_back_to_checkout( $invoice );
351
+		wpinv_send_back_to_checkout($invoice);
352 352
 
353 353
 	}
354 354
 
@@ -357,41 +357,41 @@  discard block
 block discarded – undo
357 357
 	 *
358 358
 	 * @param WPInv_Invoice $invoice
359 359
 	 */
360
-	protected function process_payment( $invoice ) {
360
+	protected function process_payment($invoice) {
361 361
 
362 362
 		// Clear any checkout errors.
363 363
 		wpinv_clear_errors();
364 364
 
365 365
 		// No need to send free invoices to the gateway.
366
-		if ( $invoice->is_free() ) {
367
-			$this->process_free_payment( $invoice );
366
+		if ($invoice->is_free()) {
367
+			$this->process_free_payment($invoice);
368 368
 		}
369 369
 
370 370
 		$submission = $this->payment_form_submission;
371 371
 
372 372
 		// Fires before sending to the gateway.
373
-		do_action( 'getpaid_checkout_before_gateway', $invoice, $submission );
373
+		do_action('getpaid_checkout_before_gateway', $invoice, $submission);
374 374
 
375 375
 		// Allow the sumission data to be modified before it is sent to the gateway.
376 376
 		$submission_data    = $submission->get_data();
377
-		$submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice );
378
-		$submission_data    = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice );
377
+		$submission_gateway = apply_filters('getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice);
378
+		$submission_data    = apply_filters('getpaid_gateway_submission_data', $submission_data, $submission, $invoice);
379 379
 
380 380
 		// Validate the currency.
381
-		if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) {
382
-			wpinv_set_error( 'invalid_currency', __( 'The chosen payment gateway does not support this currency', 'invoicing' ) );
381
+		if (!apply_filters("getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency())) {
382
+			wpinv_set_error('invalid_currency', __('The chosen payment gateway does not support this currency', 'invoicing'));
383 383
 		}
384 384
 
385 385
 		// Check to see if we have any errors.
386
-		if ( wpinv_get_errors() ) {
387
-			wpinv_send_back_to_checkout( $invoice );
386
+		if (wpinv_get_errors()) {
387
+			wpinv_send_back_to_checkout($invoice);
388 388
 		}
389 389
 
390 390
 		// Send info to the gateway for payment processing
391
-		do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission );
391
+		do_action("getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission);
392 392
 
393 393
 		// Backwards compatibility.
394
-		wpinv_send_to_gateway( $submission_gateway, $invoice );
394
+		wpinv_send_to_gateway($submission_gateway, $invoice);
395 395
 
396 396
 	}
397 397
 
@@ -400,12 +400,12 @@  discard block
 block discarded – undo
400 400
 	 *
401 401
 	 * @param WPInv_Invoice $invoice
402 402
 	 */
403
-	protected function process_free_payment( $invoice ) {
403
+	protected function process_free_payment($invoice) {
404 404
 
405
-		$invoice->set_gateway( 'none' );
406
-		$invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true );
405
+		$invoice->set_gateway('none');
406
+		$invoice->add_note(__("This is a free invoice and won't be sent to the payment gateway", 'invoicing'), false, false, true);
407 407
 		$invoice->mark_paid();
408
-		wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
408
+		wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
409 409
 
410 410
 	}
411 411
 
@@ -413,9 +413,9 @@  discard block
 block discarded – undo
413 413
      * Sends a redrect response to payment details.
414 414
      *
415 415
      */
416
-    public function send_redirect_response( $url ) {
417
-        $url = urlencode( $url );
418
-        wp_send_json_success( $url );
416
+    public function send_redirect_response($url) {
417
+        $url = urlencode($url);
418
+        wp_send_json_success($url);
419 419
     }
420 420
 
421 421
 }
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-details.php 1 patch
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,13 +21,13 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the invoice.
27
-        $invoice = new WPInv_Invoice( $post );
27
+        $invoice = new WPInv_Invoice($post);
28 28
 
29 29
         // Nonce field.
30
-        wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ;
30
+        wp_nonce_field('wpinv_details', 'wpinv_details_nonce');
31 31
 
32 32
 
33 33
         ?>
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
 
47 47
                 <div class="bsui" style="margin-top: 1.5rem">
48 48
 
49
-                    <?php do_action( 'getpaid_invoice_edit_before_viewed_by_customer', $invoice ); ?>
50
-                    <?php if ( ! $invoice->is_draft() ) : ?>
49
+                    <?php do_action('getpaid_invoice_edit_before_viewed_by_customer', $invoice); ?>
50
+                    <?php if (!$invoice->is_draft()) : ?>
51 51
                         <div class="form-group">
52
-                            <strong><?php _e( 'Viewed by Customer:', 'invoicing' );?></strong>
53
-                            <?php ( $invoice->get_is_viewed() ) ? _e( 'Yes', 'invoicing' ) : _e( 'No', 'invoicing' ); ?>
52
+                            <strong><?php _e('Viewed by Customer:', 'invoicing'); ?></strong>
53
+                            <?php ($invoice->get_is_viewed()) ? _e('Yes', 'invoicing') : _e('No', 'invoicing'); ?>
54 54
                         </div>
55 55
                     <?php endif; ?>
56 56
 
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
 
59 59
                         // Date created.
60 60
                         $label = sprintf(
61
-                            __( '%s Date:', 'invoicing' ),
62
-                            ucfirst( $invoice->get_type() )
61
+                            __('%s Date:', 'invoicing'),
62
+                            ucfirst($invoice->get_type())
63 63
                         );
64 64
 
65
-                        $info  = sprintf(
66
-                            __( 'The date this %s was created.', 'invoicing' ),
67
-                            strtolower( $invoice->get_type() )
65
+                        $info = sprintf(
66
+                            __('The date this %s was created.', 'invoicing'),
67
+                            strtolower($invoice->get_type())
68 68
                         );
69 69
 
70 70
                         echo aui()->input(
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
                                 'type'        => 'datepicker',
73 73
                                 'id'          => 'wpinv_date_created',
74 74
                                 'name'        => 'date_created',
75
-                                'label'       => $label . getpaid_get_help_tip( $info ),
75
+                                'label'       => $label . getpaid_get_help_tip($info),
76 76
                                 'label_type'  => 'vertical',
77 77
                                 'placeholder' => 'YYYY-MM-DD 00:00',
78 78
                                 'class'       => 'form-control-sm',
79
-                                'value'       => $invoice->get_date_created( 'edit' ),
79
+                                'value'       => $invoice->get_date_created('edit'),
80 80
                                 'extra_attributes' => array(
81 81
                                     'data-enable-time' => 'true',
82 82
                                     'data-time_24hr'   => 'true',
@@ -87,30 +87,30 @@  discard block
 block discarded – undo
87 87
                         );
88 88
 
89 89
                         // Due date.
90
-                        if ( $invoice->is_type( 'invoice' ) && wpinv_get_option( 'overdue_active' ) && ( $invoice->needs_payment() || $invoice->is_draft() ) ) {
90
+                        if ($invoice->is_type('invoice') && wpinv_get_option('overdue_active') && ($invoice->needs_payment() || $invoice->is_draft())) {
91 91
 
92 92
                             echo aui()->input(
93 93
                                 array(
94 94
                                     'type'        => 'text',
95 95
                                     'id'          => 'wpinv_due_date',
96 96
                                     'name'        => 'wpinv_due_date',
97
-                                    'label'       => __( 'Due Date:', 'invoicing' ) . getpaid_get_help_tip( __( 'Leave blank to disable automated reminder emails for this invoice.', 'invoicing' ) ),
97
+                                    'label'       => __('Due Date:', 'invoicing') . getpaid_get_help_tip(__('Leave blank to disable automated reminder emails for this invoice.', 'invoicing')),
98 98
                                     'label_type'  => 'vertical',
99
-                                    'placeholder' => __( 'No due date', 'invoicing' ),
99
+                                    'placeholder' => __('No due date', 'invoicing'),
100 100
                                     'class'       => 'form-control-sm',
101
-                                    'value'       => $invoice->get_due_date( 'edit' ),
101
+                                    'value'       => $invoice->get_due_date('edit'),
102 102
                                 )
103 103
                             );
104 104
 
105 105
                         }
106 106
 
107
-                        do_action( 'wpinv_meta_box_details_after_due_date', $invoice->get_id() );
108
-                        do_action( 'getpaid_metabox_after_due_date', $invoice );
107
+                        do_action('wpinv_meta_box_details_after_due_date', $invoice->get_id());
108
+                        do_action('getpaid_metabox_after_due_date', $invoice);
109 109
 
110 110
                         // Status.
111 111
                         $label = sprintf(
112
-                            __( '%s Status:', 'invoicing' ),
113
-                            ucfirst( $invoice->get_type() )
112
+                            __('%s Status:', 'invoicing'),
113
+                            ucfirst($invoice->get_type())
114 114
                         );
115 115
 
116 116
                         echo aui()->select(
@@ -119,23 +119,23 @@  discard block
 block discarded – undo
119 119
                                 'name'             => 'wpinv_status',
120 120
                                 'label'            => $label,
121 121
                                 'label_type'       => 'vertical',
122
-                                'placeholder'      => __( 'Select Status', 'invoicing' ),
123
-                                'value'            => $invoice->get_status( 'edit' ),
122
+                                'placeholder'      => __('Select Status', 'invoicing'),
123
+                                'value'            => $invoice->get_status('edit'),
124 124
                                 'select2'          => true,
125 125
                                 'data-allow-clear' => 'false',
126
-                                'options'          => wpinv_get_invoice_statuses( true, false, $invoice )
126
+                                'options'          => wpinv_get_invoice_statuses(true, false, $invoice)
127 127
                             )
128 128
                         );
129 129
 
130 130
                         // Invoice number.
131 131
                         $label = sprintf(
132
-                            __( '%s Number:', 'invoicing' ),
133
-                            ucfirst( $invoice->get_type() )
132
+                            __('%s Number:', 'invoicing'),
133
+                            ucfirst($invoice->get_type())
134 134
                         );
135 135
 
136
-                        $info  = sprintf(
137
-                            __( 'Each %s number must be unique.', 'invoicing' ),
138
-                            strtolower( $invoice->get_type() )
136
+                        $info = sprintf(
137
+                            __('Each %s number must be unique.', 'invoicing'),
138
+                            strtolower($invoice->get_type())
139 139
                         );
140 140
 
141 141
                         echo aui()->input(
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
                                 'type'        => 'text',
144 144
                                 'id'          => 'wpinv_number',
145 145
                                 'name'        => 'wpinv_number',
146
-                                'label'       => $label . getpaid_get_help_tip( $info ),
146
+                                'label'       => $label . getpaid_get_help_tip($info),
147 147
                                 'label_type'  => 'vertical',
148
-                                'placeholder' => __( 'Autogenerate', 'invoicing' ),
148
+                                'placeholder' => __('Autogenerate', 'invoicing'),
149 149
                                 'class'       => 'form-control-sm',
150
-                                'value'       => $invoice->get_number( 'edit' ),
150
+                                'value'       => $invoice->get_number('edit'),
151 151
                             )
152 152
                         );
153 153
 
@@ -157,25 +157,25 @@  discard block
 block discarded – undo
157 157
                                 'type'        => 'text',
158 158
                                 'id'          => 'wpinv_cc',
159 159
                                 'name'        => 'wpinv_cc',
160
-                                'label'       => __( 'Email CC:', 'invoicing' ) . getpaid_get_help_tip( __( 'Enter a comma separated list of other emails that should be notified about the invoice.', 'invoicing' ) ),
160
+                                'label'       => __('Email CC:', 'invoicing') . getpaid_get_help_tip(__('Enter a comma separated list of other emails that should be notified about the invoice.', 'invoicing')),
161 161
                                 'label_type'  => 'vertical',
162
-                                'placeholder' => __( '[email protected], [email protected]', 'invoicing' ),
162
+                                'placeholder' => __('[email protected], [email protected]', 'invoicing'),
163 163
                                 'class'       => 'form-control-sm',
164
-                                'value'       => $invoice->get_email_cc( 'edit' ),
164
+                                'value'       => $invoice->get_email_cc('edit'),
165 165
                             )
166 166
                         );
167 167
 
168
-                        do_action( 'wpinv_meta_box_details_inner', $invoice->get_id() );
168
+                        do_action('wpinv_meta_box_details_inner', $invoice->get_id());
169 169
 
170 170
                         // Disable taxes.
171
-                        if ( wpinv_use_taxes() && ! ( $invoice->is_paid() || $invoice->is_refunded() ) ) {
171
+                        if (wpinv_use_taxes() && !($invoice->is_paid() || $invoice->is_refunded())) {
172 172
 
173 173
                             echo aui()->input(
174 174
                                 array(
175 175
                                     'id'          => 'wpinv_taxable',
176 176
                                     'name'        => 'disable_taxes',
177 177
                                     'type'        => 'checkbox',
178
-                                    'label'       => __( 'Disable taxes', 'invoicing' ),
178
+                                    'label'       => __('Disable taxes', 'invoicing'),
179 179
                                     'value'       => '1',
180 180
                                     'checked'     => (bool) $invoice->get_disable_taxes(),
181 181
                                 )
@@ -184,17 +184,17 @@  discard block
 block discarded – undo
184 184
                         }
185 185
 
186 186
                         // Apply a discount.
187
-                        if ( $invoice->get_discount_code( 'edit' ) ) {
187
+                        if ($invoice->get_discount_code('edit')) {
188 188
 
189 189
                             echo aui()->input(
190 190
                                 array(
191 191
                                     'type'        => 'text',
192 192
                                     'id'          => 'wpinv_discount_code',
193 193
                                     'name'        => 'wpinv_discount_code',
194
-                                    'label'       => __( 'Discount Code:', 'invoicing' ),
194
+                                    'label'       => __('Discount Code:', 'invoicing'),
195 195
                                     'label_type'  => 'vertical',
196 196
                                     'class'       => 'form-control-sm',
197
-                                    'value'       => $invoice->get_discount_code( 'edit' ),
197
+                                    'value'       => $invoice->get_discount_code('edit'),
198 198
                                     'extra_attributes' => array(
199 199
                                         'onclick'  => 'this.select();',
200 200
                                         'readonly' => 'true',
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 
205 205
                         }
206 206
 
207
-                        do_action( 'getpaid_metabox_after_invoice_details', $invoice );
207
+                        do_action('getpaid_metabox_after_invoice_details', $invoice);
208 208
 
209 209
                     ?>
210 210
 
Please login to merge, or discard this patch.
invoicing.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,20 +15,20 @@  discard block
 block discarded – undo
15 15
  * @package GetPaid
16 16
  */
17 17
 
18
-defined( 'ABSPATH' ) || exit;
18
+defined('ABSPATH') || exit;
19 19
 
20 20
 // Define constants.
21
-if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) {
22
-	define( 'WPINV_PLUGIN_FILE', __FILE__ );
21
+if (!defined('WPINV_PLUGIN_FILE')) {
22
+	define('WPINV_PLUGIN_FILE', __FILE__);
23 23
 }
24 24
 
25
-if ( ! defined( 'WPINV_VERSION' ) ) {
26
-	define( 'WPINV_VERSION', '2.0.2-beta' );
25
+if (!defined('WPINV_VERSION')) {
26
+	define('WPINV_VERSION', '2.0.2-beta');
27 27
 }
28 28
 
29 29
 // Include the main Invoicing class.
30
-if ( ! class_exists( 'WPInv_Plugin', false ) ) {
31
-	require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php';
30
+if (!class_exists('WPInv_Plugin', false)) {
31
+	require_once plugin_dir_path(WPINV_PLUGIN_FILE) . 'includes/class-wpinv.php';
32 32
 }
33 33
 
34 34
 /**
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  */
40 40
 function getpaid() {
41 41
 
42
-    if ( empty( $GLOBALS['invoicing'] ) ) {
42
+    if (empty($GLOBALS['invoicing'])) {
43 43
         $GLOBALS['invoicing'] = new WPInv_Plugin();
44 44
     }
45 45
 
@@ -54,4 +54,4 @@  discard block
 block discarded – undo
54 54
 }
55 55
 
56 56
 // Kickstart the plugin.
57
-add_action( 'plugins_loaded', 'getpaid', -100 );
57
+add_action('plugins_loaded', 'getpaid', -100);
Please login to merge, or discard this patch.