Passed
Push — master ( e7f679...497566 )
by Brian
04:58
created
includes/gateways/class-getpaid-bank-transfer-gateway.php 2 patches
Indentation   +232 added lines, -232 removed lines patch added patch discarded remove patch
@@ -13,40 +13,40 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Bank_Transfer_Gateway extends GetPaid_Payment_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'bank_transfer';
21 21
 
22
-	/**
23
-	 * An array of features that this gateway supports.
24
-	 *
25
-	 * @var array
26
-	 */
27
-	protected $supports = array( 'subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups' );
22
+    /**
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27
+    protected $supports = array( 'subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups' );
28
+
29
+    /**
30
+     * Payment method order.
31
+     *
32
+     * @var int
33
+     */
34
+    public $order = 8;
35
+
36
+    /**
37
+     * Bank transfer instructions.
38
+     */
39
+    public $instructions;
28 40
 
29 41
     /**
30
-	 * Payment method order.
31
-	 *
32
-	 * @var int
33
-	 */
34
-	public $order = 8;
35
-
36
-	/**
37
-	 * Bank transfer instructions.
38
-	 */
39
-	public $instructions;
40
-
41
-	/**
42
-	 * Locale array.
43
-	 */
44
-	public $locale;
42
+     * Locale array.
43
+     */
44
+    public $locale;
45 45
 
46 46
     /**
47
-	 * Class constructor.
48
-	 */
49
-	public function __construct() {
47
+     * Class constructor.
48
+     */
49
+    public function __construct() {
50 50
         parent::__construct();
51 51
 
52 52
         $this->title                = __( 'Direct bank transfer', 'invoicing' );
@@ -54,24 +54,24 @@  discard block
 block discarded – undo
54 54
         $this->checkout_button_text = __( 'Proceed', 'invoicing' );
55 55
         $this->instructions         = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) );
56 56
 
57
-		add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
58
-		add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
59
-		add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
60
-		add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
61
-		add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) );
62
-		add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 );
57
+        add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
58
+        add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
59
+        add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
60
+        add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
61
+        add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) );
62
+        add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 );
63 63
 
64 64
     }
65 65
 
66 66
     /**
67
-	 * Process Payment.
68
-	 *
69
-	 * @param WPInv_Invoice $invoice Invoice.
70
-	 * @param array $submission_data Posted checkout fields.
71
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
72
-	 * @return array
73
-	 */
74
-	public function process_payment( $invoice, $submission_data, $submission ) {
67
+     * Process Payment.
68
+     *
69
+     * @param WPInv_Invoice $invoice Invoice.
70
+     * @param array $submission_data Posted checkout fields.
71
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
72
+     * @return array
73
+     */
74
+    public function process_payment( $invoice, $submission_data, $submission ) {
75 75
 
76 76
         // Add a transaction id.
77 77
         $invoice->set_transaction_id( $invoice->generate_key( 'bt_' ) );
@@ -92,66 +92,66 @@  discard block
 block discarded – undo
92 92
     }
93 93
 
94 94
     /**
95
-	 * Output for the order received page.
96
-	 *
97
-	 * @param WPInv_Invoice $invoice Invoice.
98
-	 */
99
-	public function thankyou_page( $invoice ) {
95
+     * Output for the order received page.
96
+     *
97
+     * @param WPInv_Invoice $invoice Invoice.
98
+     */
99
+    public function thankyou_page( $invoice ) {
100 100
 
101 101
         if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
102 102
 
103
-			echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
103
+            echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
104 104
 
105 105
             if ( ! empty( $this->instructions ) ) {
106 106
                 echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) );
107
-			}
107
+            }
108 108
 
109
-			$this->bank_details( $invoice );
109
+            $this->bank_details( $invoice );
110 110
 
111
-			echo '</div>';
111
+            echo '</div>';
112 112
 
113 113
         }
114 114
 
115
-	}
115
+    }
116 116
 
117 117
     /**
118
-	 * Add content to the WPI emails.
119
-	 *
120
-	 * @param WPInv_Invoice $invoice Invoice.
121
-	 * @param string     $email_type Email format: plain text or HTML.
122
-	 * @param bool     $sent_to_admin Sent to admin.
123
-	 */
124
-	public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
118
+     * Add content to the WPI emails.
119
+     *
120
+     * @param WPInv_Invoice $invoice Invoice.
121
+     * @param string     $email_type Email format: plain text or HTML.
122
+     * @param bool     $sent_to_admin Sent to admin.
123
+     */
124
+    public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
125 125
 
126
-		if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
126
+        if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
127 127
 
128
-			echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
128
+            echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
129 129
 
130
-			if ( $this->instructions ) {
131
-				echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
130
+            if ( $this->instructions ) {
131
+                echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
132 132
             }
133 133
 
134
-			$this->bank_details( $invoice );
134
+            $this->bank_details( $invoice );
135 135
 
136
-			echo '</div>';
136
+            echo '</div>';
137 137
 
138
-		}
138
+        }
139 139
 
140 140
     }
141 141
 
142 142
     /**
143
-	 * Get bank details and place into a list format.
144
-	 *
145
-	 * @param WPInv_Invoice $invoice Invoice.
146
-	 */
147
-	protected function bank_details( $invoice ) {
143
+     * Get bank details and place into a list format.
144
+     *
145
+     * @param WPInv_Invoice $invoice Invoice.
146
+     */
147
+    protected function bank_details( $invoice ) {
148 148
 
149
-		// Get the invoice country and country $locale.
150
-		$country = $invoice->get_country();
151
-		$locale  = $this->get_country_locale();
149
+        // Get the invoice country and country $locale.
150
+        $country = $invoice->get_country();
151
+        $locale  = $this->get_country_locale();
152 152
 
153
-		// Get sortcode label in the $locale array and use appropriate one.
154
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
153
+        // Get sortcode label in the $locale array and use appropriate one.
154
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
155 155
 
156 156
         $bank_fields = array(
157 157
             'ac_name'   => __( 'Account Name', 'invoicing' ),
@@ -170,11 +170,11 @@  discard block
 block discarded – undo
170 170
 
171 171
             if ( ! empty( $value ) ) {
172 172
                 $bank_info[ $field ] = array(
173
-					'label' => $label,
174
-					'value' => $value,
175
-				);
173
+                    'label' => $label,
174
+                    'value' => $value,
175
+                );
176 176
             }
177
-		}
177
+        }
178 178
 
179 179
         $bank_info = apply_filters( 'wpinv_bank_info', $bank_info, $invoice );
180 180
 
@@ -182,139 +182,139 @@  discard block
 block discarded – undo
182 182
             return;
183 183
         }
184 184
 
185
-		echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ), $invoice ) ) . '</h3>' . PHP_EOL;
185
+        echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ), $invoice ) ) . '</h3>' . PHP_EOL;
186
+
187
+        echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
188
+
189
+        foreach ( $bank_info as $key => $data ) {
190
+            echo "<tr class='getpaid-bank-transfer-" . esc_attr( $key ) . "'><th class='font-weight-bold'>" . wp_kses_post( $data['label'] ) . "</th><td class='w-75'>" . wp_kses_post( wptexturize( $data['value'] ) ) . '</td></tr>' . PHP_EOL;
191
+        }
192
+
193
+        echo '</table>';
194
+
195
+    }
186 196
 
187
-		echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
197
+    /**
198
+     * Get country locale if localized.
199
+     *
200
+     * @return array
201
+     */
202
+    public function get_country_locale() {
203
+
204
+        if ( empty( $this->locale ) ) {
205
+
206
+            // Locale information to be used - only those that are not 'Sort Code'.
207
+            $this->locale = apply_filters(
208
+                'getpaid_get_bank_transfer_locale',
209
+                array(
210
+                    'AU' => array(
211
+                        'sortcode' => array(
212
+                            'label' => __( 'BSB', 'invoicing' ),
213
+                        ),
214
+                    ),
215
+                    'CA' => array(
216
+                        'sortcode' => array(
217
+                            'label' => __( 'Bank transit number', 'invoicing' ),
218
+                        ),
219
+                    ),
220
+                    'IN' => array(
221
+                        'sortcode' => array(
222
+                            'label' => __( 'IFSC', 'invoicing' ),
223
+                        ),
224
+                    ),
225
+                    'IT' => array(
226
+                        'sortcode' => array(
227
+                            'label' => __( 'Branch sort', 'invoicing' ),
228
+                        ),
229
+                    ),
230
+                    'NZ' => array(
231
+                        'sortcode' => array(
232
+                            'label' => __( 'Bank code', 'invoicing' ),
233
+                        ),
234
+                    ),
235
+                    'SE' => array(
236
+                        'sortcode' => array(
237
+                            'label' => __( 'Bank code', 'invoicing' ),
238
+                        ),
239
+                    ),
240
+                    'US' => array(
241
+                        'sortcode' => array(
242
+                            'label' => __( 'Routing number', 'invoicing' ),
243
+                        ),
244
+                    ),
245
+                    'ZA' => array(
246
+                        'sortcode' => array(
247
+                            'label' => __( 'Branch code', 'invoicing' ),
248
+                        ),
249
+                    ),
250
+                )
251
+            );
188 252
 
189
-		foreach ( $bank_info as $key => $data ) {
190
-			echo "<tr class='getpaid-bank-transfer-" . esc_attr( $key ) . "'><th class='font-weight-bold'>" . wp_kses_post( $data['label'] ) . "</th><td class='w-75'>" . wp_kses_post( wptexturize( $data['value'] ) ) . '</td></tr>' . PHP_EOL;
191
-		}
253
+        }
192 254
 
193
-		echo '</table>';
255
+        return $this->locale;
194 256
 
195 257
     }
196 258
 
197 259
     /**
198
-	 * Get country locale if localized.
199
-	 *
200
-	 * @return array
201
-	 */
202
-	public function get_country_locale() {
203
-
204
-		if ( empty( $this->locale ) ) {
205
-
206
-			// Locale information to be used - only those that are not 'Sort Code'.
207
-			$this->locale = apply_filters(
208
-				'getpaid_get_bank_transfer_locale',
209
-				array(
210
-					'AU' => array(
211
-						'sortcode' => array(
212
-							'label' => __( 'BSB', 'invoicing' ),
213
-						),
214
-					),
215
-					'CA' => array(
216
-						'sortcode' => array(
217
-							'label' => __( 'Bank transit number', 'invoicing' ),
218
-						),
219
-					),
220
-					'IN' => array(
221
-						'sortcode' => array(
222
-							'label' => __( 'IFSC', 'invoicing' ),
223
-						),
224
-					),
225
-					'IT' => array(
226
-						'sortcode' => array(
227
-							'label' => __( 'Branch sort', 'invoicing' ),
228
-						),
229
-					),
230
-					'NZ' => array(
231
-						'sortcode' => array(
232
-							'label' => __( 'Bank code', 'invoicing' ),
233
-						),
234
-					),
235
-					'SE' => array(
236
-						'sortcode' => array(
237
-							'label' => __( 'Bank code', 'invoicing' ),
238
-						),
239
-					),
240
-					'US' => array(
241
-						'sortcode' => array(
242
-							'label' => __( 'Routing number', 'invoicing' ),
243
-						),
244
-					),
245
-					'ZA' => array(
246
-						'sortcode' => array(
247
-							'label' => __( 'Branch code', 'invoicing' ),
248
-						),
249
-					),
250
-				)
251
-			);
252
-
253
-		}
254
-
255
-		return $this->locale;
256
-
257
-	}
258
-
259
-	/**
260
-	 * Filters the gateway settings.
261
-	 *
262
-	 * @param array $admin_settings
263
-	 */
264
-	public function admin_settings( $admin_settings ) {
260
+     * Filters the gateway settings.
261
+     *
262
+     * @param array $admin_settings
263
+     */
264
+    public function admin_settings( $admin_settings ) {
265 265
 
266 266
         $admin_settings['bank_transfer_desc']['std']    = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' );
267
-		$admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
267
+        $admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
268 268
 
269
-		$locale  = $this->get_country_locale();
269
+        $locale  = $this->get_country_locale();
270 270
 
271
-		// Get sortcode label in the $locale array and use appropriate one.
272
-		$country  = wpinv_default_billing_country();
273
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
271
+        // Get sortcode label in the $locale array and use appropriate one.
272
+        $country  = wpinv_default_billing_country();
273
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
274 274
 
275
-		$admin_settings['bank_transfer_ac_name'] = array(
275
+        $admin_settings['bank_transfer_ac_name'] = array(
276 276
             'type' => 'text',
277 277
             'id'   => 'bank_transfer_ac_name',
278 278
             'name' => __( 'Account Name', 'invoicing' ),
279
-		);
279
+        );
280 280
 
281
-		$admin_settings['bank_transfer_ac_no'] = array(
281
+        $admin_settings['bank_transfer_ac_no'] = array(
282 282
             'type' => 'text',
283 283
             'id'   => 'bank_transfer_ac_no',
284 284
             'name' => __( 'Account Number', 'invoicing' ),
285
-		);
285
+        );
286 286
 
287
-		$admin_settings['bank_transfer_bank_name'] = array(
287
+        $admin_settings['bank_transfer_bank_name'] = array(
288 288
             'type' => 'text',
289 289
             'id'   => 'bank_transfer_bank_name',
290 290
             'name' => __( 'Bank Name', 'invoicing' ),
291
-		);
291
+        );
292 292
 
293
-		$admin_settings['bank_transfer_ifsc'] = array(
293
+        $admin_settings['bank_transfer_ifsc'] = array(
294 294
             'type' => 'text',
295 295
             'id'   => 'bank_transfer_ifsc',
296 296
             'name' => __( 'IFSC Code', 'invoicing' ),
297
-		);
297
+        );
298 298
 
299
-		$admin_settings['bank_transfer_iban'] = array(
299
+        $admin_settings['bank_transfer_iban'] = array(
300 300
             'type' => 'text',
301 301
             'id'   => 'bank_transfer_iban',
302 302
             'name' => __( 'IBAN', 'invoicing' ),
303
-		);
303
+        );
304 304
 
305
-		$admin_settings['bank_transfer_bic'] = array(
305
+        $admin_settings['bank_transfer_bic'] = array(
306 306
             'type' => 'text',
307 307
             'id'   => 'bank_transfer_bic',
308 308
             'name' => __( 'BIC/Swift Code', 'invoicing' ),
309
-		);
309
+        );
310 310
 
311
-		$admin_settings['bank_transfer_sort_code'] = array(
312
-			'type' => 'text',
313
-			'id'   => 'bank_transfer_sort_code',
314
-			'name' => $sortcode,
315
-		);
311
+        $admin_settings['bank_transfer_sort_code'] = array(
312
+            'type' => 'text',
313
+            'id'   => 'bank_transfer_sort_code',
314
+            'name' => $sortcode,
315
+        );
316 316
 
317
-		$admin_settings['bank_transfer_info'] = array(
317
+        $admin_settings['bank_transfer_info'] = array(
318 318
             'id'   => 'bank_transfer_info',
319 319
             'name' => __( 'Instructions', 'invoicing' ),
320 320
             'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
@@ -324,17 +324,17 @@  discard block
 block discarded – undo
324 324
             'rows' => 5,
325 325
         );
326 326
 
327
-		return $admin_settings;
328
-	}
327
+        return $admin_settings;
328
+    }
329 329
 
330
-	/**
331
-	 * Processes invoice addons.
332
-	 *
333
-	 * @param WPInv_Invoice $invoice
334
-	 * @param GetPaid_Form_Item[] $items
335
-	 * @return WPInv_Invoice
336
-	 */
337
-	public function process_addons( $invoice, $items ) {
330
+    /**
331
+     * Processes invoice addons.
332
+     *
333
+     * @param WPInv_Invoice $invoice
334
+     * @param GetPaid_Form_Item[] $items
335
+     * @return WPInv_Invoice
336
+     */
337
+    public function process_addons( $invoice, $items ) {
338 338
 
339 339
         foreach ( $items as $item ) {
340 340
             $invoice->add_item( $item );
@@ -342,66 +342,66 @@  discard block
 block discarded – undo
342 342
 
343 343
         $invoice->recalculate_total();
344 344
         $invoice->save();
345
-	}
345
+    }
346 346
 
347
-	/**
348
-	 * (Maybe) renews a bank transfer subscription profile.
349
-	 *
350
-	 *
347
+    /**
348
+     * (Maybe) renews a bank transfer subscription profile.
349
+     *
350
+     *
351 351
      * @param WPInv_Subscription $subscription
352
-	 */
353
-	public function maybe_renew_subscription( $subscription ) {
352
+     */
353
+    public function maybe_renew_subscription( $subscription ) {
354 354
 
355 355
         // Ensure its our subscription && it's active.
356 356
         if ( $this->id === $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
357
-			$subscription->create_payment();
357
+            $subscription->create_payment();
358 358
         }
359 359
 
360 360
     }
361 361
 
362
-	/**
363
-	 * Process a bank transfer payment.
364
-	 *
365
-	 *
362
+    /**
363
+     * Process a bank transfer payment.
364
+     *
365
+     *
366 366
      * @param WPInv_Invoice $invoice
367
-	 */
368
-	public function invoice_paid( $invoice ) {
369
-
370
-		// Abort if not paid by bank transfer.
371
-		if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) {
372
-			return;
373
-		}
374
-
375
-		// Is it a parent payment?
376
-		if ( 0 == $invoice->get_parent_id() ) {
377
-
378
-			// (Maybe) activate subscriptions.
379
-			$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
380
-
381
-			if ( ! empty( $subscriptions ) ) {
382
-				$subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
383
-
384
-				foreach ( $subscriptions as $subscription ) {
385
-					if ( $subscription->exists() ) {
386
-						$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
387
-						$expiry   = gmdate( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
388
-
389
-						$subscription->set_next_renewal_date( $expiry );
390
-						$subscription->set_date_created( current_time( 'mysql' ) );
391
-						$subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() );
392
-						$subscription->activate();
393
-					}
394
-				}
367
+     */
368
+    public function invoice_paid( $invoice ) {
369
+
370
+        // Abort if not paid by bank transfer.
371
+        if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) {
372
+            return;
373
+        }
374
+
375
+        // Is it a parent payment?
376
+        if ( 0 == $invoice->get_parent_id() ) {
377
+
378
+            // (Maybe) activate subscriptions.
379
+            $subscriptions = getpaid_get_invoice_subscriptions( $invoice );
380
+
381
+            if ( ! empty( $subscriptions ) ) {
382
+                $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
383
+
384
+                foreach ( $subscriptions as $subscription ) {
385
+                    if ( $subscription->exists() ) {
386
+                        $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
387
+                        $expiry   = gmdate( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
388
+
389
+                        $subscription->set_next_renewal_date( $expiry );
390
+                        $subscription->set_date_created( current_time( 'mysql' ) );
391
+                        $subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() );
392
+                        $subscription->activate();
393
+                    }
394
+                }
395 395
 }
396 396
 } else {
397 397
 
398
-			$subscription = getpaid_get_subscription( $invoice->get_subscription_id() );
398
+            $subscription = getpaid_get_subscription( $invoice->get_subscription_id() );
399 399
 
400
-			// Renew the subscription.
401
-			if ( $subscription && $subscription->exists() ) {
402
-				$subscription->add_payment( array(), $invoice );
403
-				$subscription->renew( strtotime( $invoice->get_date_created() ) );
404
-					}
400
+            // Renew the subscription.
401
+            if ( $subscription && $subscription->exists() ) {
402
+                $subscription->add_payment( array(), $invoice );
403
+                $subscription->renew( strtotime( $invoice->get_date_created() ) );
404
+                    }
405 405
 }
406 406
 
407 407
     }
Please login to merge, or discard this patch.
Spacing   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Bank transfer Payment Gateway class.
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @var array
26 26
 	 */
27
-	protected $supports = array( 'subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups' );
27
+	protected $supports = array('subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups');
28 28
 
29 29
     /**
30 30
 	 * Payment method order.
@@ -49,17 +49,17 @@  discard block
 block discarded – undo
49 49
 	public function __construct() {
50 50
         parent::__construct();
51 51
 
52
-        $this->title                = __( 'Direct bank transfer', 'invoicing' );
53
-        $this->method_title         = __( 'Bank transfer', 'invoicing' );
54
-        $this->checkout_button_text = __( 'Proceed', 'invoicing' );
55
-        $this->instructions         = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) );
52
+        $this->title                = __('Direct bank transfer', 'invoicing');
53
+        $this->method_title         = __('Bank transfer', 'invoicing');
54
+        $this->checkout_button_text = __('Proceed', 'invoicing');
55
+        $this->instructions         = apply_filters('wpinv_bank_instructions', $this->get_option('info'));
56 56
 
57
-		add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
58
-		add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
59
-		add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
60
-		add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
61
-		add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) );
62
-		add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 );
57
+		add_action('wpinv_receipt_end', array($this, 'thankyou_page'));
58
+		add_action('getpaid_invoice_line_items', array($this, 'thankyou_page'), 40);
59
+		add_action('wpinv_pdf_content_billing', array($this, 'thankyou_page'), 11);
60
+		add_action('wpinv_email_invoice_details', array($this, 'email_instructions'), 10, 3);
61
+		add_action('getpaid_should_renew_subscription', array($this, 'maybe_renew_subscription'));
62
+		add_action('getpaid_invoice_status_publish', array($this, 'invoice_paid'), 20);
63 63
 
64 64
     }
65 65
 
@@ -71,23 +71,23 @@  discard block
 block discarded – undo
71 71
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
72 72
 	 * @return array
73 73
 	 */
74
-	public function process_payment( $invoice, $submission_data, $submission ) {
74
+	public function process_payment($invoice, $submission_data, $submission) {
75 75
 
76 76
         // Add a transaction id.
77
-        $invoice->set_transaction_id( $invoice->generate_key( 'bt_' ) );
77
+        $invoice->set_transaction_id($invoice->generate_key('bt_'));
78 78
 
79 79
         // Set it as pending payment.
80
-        if ( ! $invoice->needs_payment() ) {
80
+        if (!$invoice->needs_payment()) {
81 81
             $invoice->mark_paid();
82
-        } elseif ( ! $invoice->is_paid() ) {
83
-            $invoice->set_status( 'wpi-onhold' );
82
+        } elseif (!$invoice->is_paid()) {
83
+            $invoice->set_status('wpi-onhold');
84 84
         }
85 85
 
86 86
         // Save it.
87 87
         $invoice->save();
88 88
 
89 89
         // Send to the success page.
90
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
90
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
91 91
 
92 92
     }
93 93
 
@@ -96,17 +96,17 @@  discard block
 block discarded – undo
96 96
 	 *
97 97
 	 * @param WPInv_Invoice $invoice Invoice.
98 98
 	 */
99
-	public function thankyou_page( $invoice ) {
99
+	public function thankyou_page($invoice) {
100 100
 
101
-        if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
101
+        if ('bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) {
102 102
 
103 103
 			echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
104 104
 
105
-            if ( ! empty( $this->instructions ) ) {
106
-                echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) );
105
+            if (!empty($this->instructions)) {
106
+                echo wp_kses_post(wpautop(wptexturize($this->instructions)));
107 107
 			}
108 108
 
109
-			$this->bank_details( $invoice );
109
+			$this->bank_details($invoice);
110 110
 
111 111
 			echo '</div>';
112 112
 
@@ -121,17 +121,17 @@  discard block
 block discarded – undo
121 121
 	 * @param string     $email_type Email format: plain text or HTML.
122 122
 	 * @param bool     $sent_to_admin Sent to admin.
123 123
 	 */
124
-	public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
124
+	public function email_instructions($invoice, $email_type, $sent_to_admin) {
125 125
 
126
-		if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
126
+		if (!$sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) {
127 127
 
128 128
 			echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
129 129
 
130
-			if ( $this->instructions ) {
131
-				echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
130
+			if ($this->instructions) {
131
+				echo wp_kses_post(wpautop(wptexturize($this->instructions)) . PHP_EOL);
132 132
             }
133 133
 
134
-			$this->bank_details( $invoice );
134
+			$this->bank_details($invoice);
135 135
 
136 136
 			echo '</div>';
137 137
 
@@ -144,50 +144,50 @@  discard block
 block discarded – undo
144 144
 	 *
145 145
 	 * @param WPInv_Invoice $invoice Invoice.
146 146
 	 */
147
-	protected function bank_details( $invoice ) {
147
+	protected function bank_details($invoice) {
148 148
 
149 149
 		// Get the invoice country and country $locale.
150 150
 		$country = $invoice->get_country();
151 151
 		$locale  = $this->get_country_locale();
152 152
 
153 153
 		// Get sortcode label in the $locale array and use appropriate one.
154
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
154
+		$sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing');
155 155
 
156 156
         $bank_fields = array(
157
-            'ac_name'   => __( 'Account Name', 'invoicing' ),
158
-            'ac_no'     => __( 'Account Number', 'invoicing' ),
159
-            'bank_name' => __( 'Bank Name', 'invoicing' ),
160
-            'ifsc'      => __( 'IFSC code', 'invoicing' ),
161
-            'iban'      => __( 'IBAN', 'invoicing' ),
162
-            'bic'       => __( 'BIC/Swift code', 'invoicing' ),
157
+            'ac_name'   => __('Account Name', 'invoicing'),
158
+            'ac_no'     => __('Account Number', 'invoicing'),
159
+            'bank_name' => __('Bank Name', 'invoicing'),
160
+            'ifsc'      => __('IFSC code', 'invoicing'),
161
+            'iban'      => __('IBAN', 'invoicing'),
162
+            'bic'       => __('BIC/Swift code', 'invoicing'),
163 163
             'sort_code' => $sortcode,
164 164
         );
165 165
 
166 166
         $bank_info = array();
167 167
 
168
-        foreach ( $bank_fields as $field => $label ) {
169
-            $value = $this->get_option( $field );
168
+        foreach ($bank_fields as $field => $label) {
169
+            $value = $this->get_option($field);
170 170
 
171
-            if ( ! empty( $value ) ) {
172
-                $bank_info[ $field ] = array(
171
+            if (!empty($value)) {
172
+                $bank_info[$field] = array(
173 173
 					'label' => $label,
174 174
 					'value' => $value,
175 175
 				);
176 176
             }
177 177
 		}
178 178
 
179
-        $bank_info = apply_filters( 'wpinv_bank_info', $bank_info, $invoice );
179
+        $bank_info = apply_filters('wpinv_bank_info', $bank_info, $invoice);
180 180
 
181
-        if ( empty( $bank_info ) ) {
181
+        if (empty($bank_info)) {
182 182
             return;
183 183
         }
184 184
 
185
-		echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ), $invoice ) ) . '</h3>' . PHP_EOL;
185
+		echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html(apply_filters('wpinv_receipt_bank_details_title', __('Bank Details', 'invoicing'), $invoice)) . '</h3>' . PHP_EOL;
186 186
 
187 187
 		echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
188 188
 
189
-		foreach ( $bank_info as $key => $data ) {
190
-			echo "<tr class='getpaid-bank-transfer-" . esc_attr( $key ) . "'><th class='font-weight-bold'>" . wp_kses_post( $data['label'] ) . "</th><td class='w-75'>" . wp_kses_post( wptexturize( $data['value'] ) ) . '</td></tr>' . PHP_EOL;
189
+		foreach ($bank_info as $key => $data) {
190
+			echo "<tr class='getpaid-bank-transfer-" . esc_attr($key) . "'><th class='font-weight-bold'>" . wp_kses_post($data['label']) . "</th><td class='w-75'>" . wp_kses_post(wptexturize($data['value'])) . '</td></tr>' . PHP_EOL;
191 191
 		}
192 192
 
193 193
 		echo '</table>';
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	 */
202 202
 	public function get_country_locale() {
203 203
 
204
-		if ( empty( $this->locale ) ) {
204
+		if (empty($this->locale)) {
205 205
 
206 206
 			// Locale information to be used - only those that are not 'Sort Code'.
207 207
 			$this->locale = apply_filters(
@@ -209,42 +209,42 @@  discard block
 block discarded – undo
209 209
 				array(
210 210
 					'AU' => array(
211 211
 						'sortcode' => array(
212
-							'label' => __( 'BSB', 'invoicing' ),
212
+							'label' => __('BSB', 'invoicing'),
213 213
 						),
214 214
 					),
215 215
 					'CA' => array(
216 216
 						'sortcode' => array(
217
-							'label' => __( 'Bank transit number', 'invoicing' ),
217
+							'label' => __('Bank transit number', 'invoicing'),
218 218
 						),
219 219
 					),
220 220
 					'IN' => array(
221 221
 						'sortcode' => array(
222
-							'label' => __( 'IFSC', 'invoicing' ),
222
+							'label' => __('IFSC', 'invoicing'),
223 223
 						),
224 224
 					),
225 225
 					'IT' => array(
226 226
 						'sortcode' => array(
227
-							'label' => __( 'Branch sort', 'invoicing' ),
227
+							'label' => __('Branch sort', 'invoicing'),
228 228
 						),
229 229
 					),
230 230
 					'NZ' => array(
231 231
 						'sortcode' => array(
232
-							'label' => __( 'Bank code', 'invoicing' ),
232
+							'label' => __('Bank code', 'invoicing'),
233 233
 						),
234 234
 					),
235 235
 					'SE' => array(
236 236
 						'sortcode' => array(
237
-							'label' => __( 'Bank code', 'invoicing' ),
237
+							'label' => __('Bank code', 'invoicing'),
238 238
 						),
239 239
 					),
240 240
 					'US' => array(
241 241
 						'sortcode' => array(
242
-							'label' => __( 'Routing number', 'invoicing' ),
242
+							'label' => __('Routing number', 'invoicing'),
243 243
 						),
244 244
 					),
245 245
 					'ZA' => array(
246 246
 						'sortcode' => array(
247
-							'label' => __( 'Branch code', 'invoicing' ),
247
+							'label' => __('Branch code', 'invoicing'),
248 248
 						),
249 249
 					),
250 250
 				)
@@ -261,51 +261,51 @@  discard block
 block discarded – undo
261 261
 	 *
262 262
 	 * @param array $admin_settings
263 263
 	 */
264
-	public function admin_settings( $admin_settings ) {
264
+	public function admin_settings($admin_settings) {
265 265
 
266
-        $admin_settings['bank_transfer_desc']['std']    = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' );
267
-		$admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
266
+        $admin_settings['bank_transfer_desc']['std'] = __("Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing');
267
+		$admin_settings['bank_transfer_active']['desc'] = __('Enable bank transfer', 'invoicing');
268 268
 
269
-		$locale  = $this->get_country_locale();
269
+		$locale = $this->get_country_locale();
270 270
 
271 271
 		// Get sortcode label in the $locale array and use appropriate one.
272 272
 		$country  = wpinv_default_billing_country();
273
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
273
+		$sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing');
274 274
 
275 275
 		$admin_settings['bank_transfer_ac_name'] = array(
276 276
             'type' => 'text',
277 277
             'id'   => 'bank_transfer_ac_name',
278
-            'name' => __( 'Account Name', 'invoicing' ),
278
+            'name' => __('Account Name', 'invoicing'),
279 279
 		);
280 280
 
281 281
 		$admin_settings['bank_transfer_ac_no'] = array(
282 282
             'type' => 'text',
283 283
             'id'   => 'bank_transfer_ac_no',
284
-            'name' => __( 'Account Number', 'invoicing' ),
284
+            'name' => __('Account Number', 'invoicing'),
285 285
 		);
286 286
 
287 287
 		$admin_settings['bank_transfer_bank_name'] = array(
288 288
             'type' => 'text',
289 289
             'id'   => 'bank_transfer_bank_name',
290
-            'name' => __( 'Bank Name', 'invoicing' ),
290
+            'name' => __('Bank Name', 'invoicing'),
291 291
 		);
292 292
 
293 293
 		$admin_settings['bank_transfer_ifsc'] = array(
294 294
             'type' => 'text',
295 295
             'id'   => 'bank_transfer_ifsc',
296
-            'name' => __( 'IFSC Code', 'invoicing' ),
296
+            'name' => __('IFSC Code', 'invoicing'),
297 297
 		);
298 298
 
299 299
 		$admin_settings['bank_transfer_iban'] = array(
300 300
             'type' => 'text',
301 301
             'id'   => 'bank_transfer_iban',
302
-            'name' => __( 'IBAN', 'invoicing' ),
302
+            'name' => __('IBAN', 'invoicing'),
303 303
 		);
304 304
 
305 305
 		$admin_settings['bank_transfer_bic'] = array(
306 306
             'type' => 'text',
307 307
             'id'   => 'bank_transfer_bic',
308
-            'name' => __( 'BIC/Swift Code', 'invoicing' ),
308
+            'name' => __('BIC/Swift Code', 'invoicing'),
309 309
 		);
310 310
 
311 311
 		$admin_settings['bank_transfer_sort_code'] = array(
@@ -316,10 +316,10 @@  discard block
 block discarded – undo
316 316
 
317 317
 		$admin_settings['bank_transfer_info'] = array(
318 318
             'id'   => 'bank_transfer_info',
319
-            'name' => __( 'Instructions', 'invoicing' ),
320
-            'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
319
+            'name' => __('Instructions', 'invoicing'),
320
+            'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'),
321 321
             'type' => 'textarea',
322
-            'std'  => __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' ),
322
+            'std'  => __("Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing'),
323 323
             'cols' => 50,
324 324
             'rows' => 5,
325 325
         );
@@ -334,10 +334,10 @@  discard block
 block discarded – undo
334 334
 	 * @param GetPaid_Form_Item[] $items
335 335
 	 * @return WPInv_Invoice
336 336
 	 */
337
-	public function process_addons( $invoice, $items ) {
337
+	public function process_addons($invoice, $items) {
338 338
 
339
-        foreach ( $items as $item ) {
340
-            $invoice->add_item( $item );
339
+        foreach ($items as $item) {
340
+            $invoice->add_item($item);
341 341
         }
342 342
 
343 343
         $invoice->recalculate_total();
@@ -350,10 +350,10 @@  discard block
 block discarded – undo
350 350
 	 *
351 351
      * @param WPInv_Subscription $subscription
352 352
 	 */
353
-	public function maybe_renew_subscription( $subscription ) {
353
+	public function maybe_renew_subscription($subscription) {
354 354
 
355 355
         // Ensure its our subscription && it's active.
356
-        if ( $this->id === $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
356
+        if ($this->id === $subscription->get_gateway() && $subscription->has_status('active trialling')) {
357 357
 			$subscription->create_payment();
358 358
         }
359 359
 
@@ -365,42 +365,42 @@  discard block
 block discarded – undo
365 365
 	 *
366 366
      * @param WPInv_Invoice $invoice
367 367
 	 */
368
-	public function invoice_paid( $invoice ) {
368
+	public function invoice_paid($invoice) {
369 369
 
370 370
 		// Abort if not paid by bank transfer.
371
-		if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) {
371
+		if ($this->id !== $invoice->get_gateway() || !$invoice->is_recurring()) {
372 372
 			return;
373 373
 		}
374 374
 
375 375
 		// Is it a parent payment?
376
-		if ( 0 == $invoice->get_parent_id() ) {
376
+		if (0 == $invoice->get_parent_id()) {
377 377
 
378 378
 			// (Maybe) activate subscriptions.
379
-			$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
379
+			$subscriptions = getpaid_get_invoice_subscriptions($invoice);
380 380
 
381
-			if ( ! empty( $subscriptions ) ) {
382
-				$subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
381
+			if (!empty($subscriptions)) {
382
+				$subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions);
383 383
 
384
-				foreach ( $subscriptions as $subscription ) {
385
-					if ( $subscription->exists() ) {
386
-						$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
387
-						$expiry   = gmdate( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
384
+				foreach ($subscriptions as $subscription) {
385
+					if ($subscription->exists()) {
386
+						$duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created());
387
+						$expiry   = gmdate('Y-m-d H:i:s', (current_time('timestamp') + $duration));
388 388
 
389
-						$subscription->set_next_renewal_date( $expiry );
390
-						$subscription->set_date_created( current_time( 'mysql' ) );
391
-						$subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() );
389
+						$subscription->set_next_renewal_date($expiry);
390
+						$subscription->set_date_created(current_time('mysql'));
391
+						$subscription->set_profile_id('bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id());
392 392
 						$subscription->activate();
393 393
 					}
394 394
 				}
395 395
 }
396 396
 } else {
397 397
 
398
-			$subscription = getpaid_get_subscription( $invoice->get_subscription_id() );
398
+			$subscription = getpaid_get_subscription($invoice->get_subscription_id());
399 399
 
400 400
 			// Renew the subscription.
401
-			if ( $subscription && $subscription->exists() ) {
402
-				$subscription->add_payment( array(), $invoice );
403
-				$subscription->renew( strtotime( $invoice->get_date_created() ) );
401
+			if ($subscription && $subscription->exists()) {
402
+				$subscription->add_payment(array(), $invoice);
403
+				$subscription->renew(strtotime($invoice->get_date_created()));
404 404
 					}
405 405
 }
406 406
 
Please login to merge, or discard this patch.
invoicing.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,16 +19,16 @@  discard block
 block discarded – undo
19 19
 
20 20
 // Define constants.
21 21
 if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) {
22
-	define( 'WPINV_PLUGIN_FILE', __FILE__ );
22
+    define( 'WPINV_PLUGIN_FILE', __FILE__ );
23 23
 }
24 24
 
25 25
 if ( ! defined( 'WPINV_VERSION' ) ) {
26
-	define( 'WPINV_VERSION', '2.7.3' );
26
+    define( 'WPINV_VERSION', '2.7.3' );
27 27
 }
28 28
 
29 29
 // Include the main Invoicing class.
30 30
 if ( ! class_exists( 'WPInv_Plugin', false ) ) {
31
-	require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php';
31
+    require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php';
32 32
 }
33 33
 
34 34
 /**
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         $GLOBALS['invoicing'] = new WPInv_Plugin();
44 44
     }
45 45
 
46
-	return $GLOBALS['invoicing'];
46
+    return $GLOBALS['invoicing'];
47 47
 }
48 48
 
49 49
 /**
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 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.7.3' );
25
+if (!defined('WPINV_VERSION')) {
26
+	define('WPINV_VERSION', '2.7.3');
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
 
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
  * @since  2.0.8
53 53
  */
54 54
 function getpaid_deactivation_hook() {
55
-    update_option( 'wpinv_flush_permalinks', 1 );
55
+    update_option('wpinv_flush_permalinks', 1);
56 56
 }
57
-register_deactivation_hook( __FILE__, 'getpaid_deactivation_hook' );
57
+register_deactivation_hook(__FILE__, 'getpaid_deactivation_hook');
58 58
 
59 59
 /**
60 60
  * @deprecated
@@ -64,4 +64,4 @@  discard block
 block discarded – undo
64 64
 }
65 65
 
66 66
 // Kickstart the plugin.
67
-add_action( 'plugins_loaded', 'getpaid', -100 );
67
+add_action('plugins_loaded', 'getpaid', -100);
Please login to merge, or discard this patch.