Passed
Push — master ( 31f474...7d7341 )
by Kiran
10:27 queued 05:04
created
includes/gateways/class-getpaid-bank-transfer-gateway.php 2 patches
Indentation   +363 added lines, -363 removed lines patch added patch discarded remove patch
@@ -13,47 +13,47 @@  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(
28
-		'subscription',
29
-		'addons',
30
-		'single_subscription_group',
31
-		'multiple_subscription_groups',
32
-		'subscription_date_change',
33
-		'subscription_bill_times_change',
34
-	);
22
+    /**
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27
+    protected $supports = array(
28
+        'subscription',
29
+        'addons',
30
+        'single_subscription_group',
31
+        'multiple_subscription_groups',
32
+        'subscription_date_change',
33
+        'subscription_bill_times_change',
34
+    );
35
+
36
+    /**
37
+     * Payment method order.
38
+     *
39
+     * @var int
40
+     */
41
+    public $order = 8;
42
+
43
+    /**
44
+     * Bank transfer instructions.
45
+     */
46
+    public $instructions;
35 47
 
36 48
     /**
37
-	 * Payment method order.
38
-	 *
39
-	 * @var int
40
-	 */
41
-	public $order = 8;
42
-
43
-	/**
44
-	 * Bank transfer instructions.
45
-	 */
46
-	public $instructions;
47
-
48
-	/**
49
-	 * Locale array.
50
-	 */
51
-	public $locale;
49
+     * Locale array.
50
+     */
51
+    public $locale;
52 52
 
53 53
     /**
54
-	 * Class constructor.
55
-	 */
56
-	public function __construct() {
54
+     * Class constructor.
55
+     */
56
+    public function __construct() {
57 57
         parent::__construct();
58 58
 
59 59
         $this->title                = __( 'Direct bank transfer', 'invoicing' );
@@ -61,43 +61,43 @@  discard block
 block discarded – undo
61 61
         $this->checkout_button_text = __( 'Proceed', 'invoicing' );
62 62
         $this->instructions         = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) );
63 63
 
64
-		add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
65
-		add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
66
-		add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
67
-		add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
68
-		add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ), 12, 2 );
69
-		add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 );
70
-
71
-		add_filter( 'wpinv_' . $this->id . '_support_subscription', array( $this, 'supports_subscription' ), 20, 1 );
72
-		add_filter( 'getpaid_' . $this->id . '_support_subscription', array( $this, 'supports_subscription' ), 20, 1 );
73
-		add_filter( 'getpaid_' . $this->id . '_supports_subscription', array( $this, 'supports_subscription' ), 20, 1 );
74
-	}
75
-
76
-	/**
77
-	 * Check gateway supports for subscription.
78
-	 *
79
-	 * @since 2.8.24
80
-	 *
81
-	 * @param bool $supports True if supports else False.
82
-	 * @return bool True if supports else False.
83
-	 */
84
-	public function supports_subscription( $supports ) {
85
-		if ( $supports && (int) $this->get_option( 'no_subscription' ) ) {
86
-			$supports = false;
87
-		}
88
-
89
-		return $supports;
90
-	}
91
-
92
-	/**
93
-	 * Process Payment.
94
-	 *
95
-	 * @param WPInv_Invoice $invoice Invoice.
96
-	 * @param array $submission_data Posted checkout fields.
97
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
98
-	 * @return array
99
-	 */
100
-	public function process_payment( $invoice, $submission_data, $submission ) {
64
+        add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
65
+        add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
66
+        add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
67
+        add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
68
+        add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ), 12, 2 );
69
+        add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 );
70
+
71
+        add_filter( 'wpinv_' . $this->id . '_support_subscription', array( $this, 'supports_subscription' ), 20, 1 );
72
+        add_filter( 'getpaid_' . $this->id . '_support_subscription', array( $this, 'supports_subscription' ), 20, 1 );
73
+        add_filter( 'getpaid_' . $this->id . '_supports_subscription', array( $this, 'supports_subscription' ), 20, 1 );
74
+    }
75
+
76
+    /**
77
+     * Check gateway supports for subscription.
78
+     *
79
+     * @since 2.8.24
80
+     *
81
+     * @param bool $supports True if supports else False.
82
+     * @return bool True if supports else False.
83
+     */
84
+    public function supports_subscription( $supports ) {
85
+        if ( $supports && (int) $this->get_option( 'no_subscription' ) ) {
86
+            $supports = false;
87
+        }
88
+
89
+        return $supports;
90
+    }
91
+
92
+    /**
93
+     * Process Payment.
94
+     *
95
+     * @param WPInv_Invoice $invoice Invoice.
96
+     * @param array $submission_data Posted checkout fields.
97
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
98
+     * @return array
99
+     */
100
+    public function process_payment( $invoice, $submission_data, $submission ) {
101 101
 
102 102
         // Add a transaction id.
103 103
         $invoice->set_transaction_id( $invoice->generate_key( 'bt_' ) );
@@ -118,66 +118,66 @@  discard block
 block discarded – undo
118 118
     }
119 119
 
120 120
     /**
121
-	 * Output for the order received page.
122
-	 *
123
-	 * @param WPInv_Invoice $invoice Invoice.
124
-	 */
125
-	public function thankyou_page( $invoice ) {
121
+     * Output for the order received page.
122
+     *
123
+     * @param WPInv_Invoice $invoice Invoice.
124
+     */
125
+    public function thankyou_page( $invoice ) {
126 126
 
127 127
         if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
128 128
 
129
-			echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
129
+            echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
130 130
 
131 131
             if ( ! empty( $this->instructions ) ) {
132 132
                 echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) );
133
-			}
133
+            }
134 134
 
135
-			$this->bank_details( $invoice );
135
+            $this->bank_details( $invoice );
136 136
 
137
-			echo '</div>';
137
+            echo '</div>';
138 138
 
139 139
         }
140 140
 
141
-	}
141
+    }
142 142
 
143 143
     /**
144
-	 * Add content to the WPI emails.
145
-	 *
146
-	 * @param WPInv_Invoice $invoice Invoice.
147
-	 * @param string     $email_type Email format: plain text or HTML.
148
-	 * @param bool     $sent_to_admin Sent to admin.
149
-	 */
150
-	public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
144
+     * Add content to the WPI emails.
145
+     *
146
+     * @param WPInv_Invoice $invoice Invoice.
147
+     * @param string     $email_type Email format: plain text or HTML.
148
+     * @param bool     $sent_to_admin Sent to admin.
149
+     */
150
+    public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
151 151
 
152
-		if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
152
+        if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
153 153
 
154
-			echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
154
+            echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
155 155
 
156
-			if ( $this->instructions ) {
157
-				echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
156
+            if ( $this->instructions ) {
157
+                echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
158 158
             }
159 159
 
160
-			$this->bank_details( $invoice );
160
+            $this->bank_details( $invoice );
161 161
 
162
-			echo '</div>';
162
+            echo '</div>';
163 163
 
164
-		}
164
+        }
165 165
 
166 166
     }
167 167
 
168 168
     /**
169
-	 * Get bank details and place into a list format.
170
-	 *
171
-	 * @param WPInv_Invoice $invoice Invoice.
172
-	 */
173
-	protected function bank_details( $invoice ) {
169
+     * Get bank details and place into a list format.
170
+     *
171
+     * @param WPInv_Invoice $invoice Invoice.
172
+     */
173
+    protected function bank_details( $invoice ) {
174 174
 
175
-		// Get the invoice country and country $locale.
176
-		$country = $invoice->get_country();
177
-		$locale  = $this->get_country_locale();
175
+        // Get the invoice country and country $locale.
176
+        $country = $invoice->get_country();
177
+        $locale  = $this->get_country_locale();
178 178
 
179
-		// Get shortcode label in the $locale array and use appropriate one.
180
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
179
+        // Get shortcode label in the $locale array and use appropriate one.
180
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
181 181
 
182 182
         $bank_fields = array(
183 183
             'ac_name'   => __( 'Account Name', 'invoicing' ),
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
 
197 197
             if ( ! empty( $value ) ) {
198 198
                 $bank_info[ $field ] = array(
199
-					'label' => $label,
200
-					'value' => $value,
201
-				);
199
+                    'label' => $label,
200
+                    'value' => $value,
201
+                );
202 202
             }
203
-		}
203
+        }
204 204
 
205 205
         $bank_info = apply_filters( 'wpinv_bank_info', $bank_info, $invoice );
206 206
 
@@ -208,177 +208,177 @@  discard block
 block discarded – undo
208 208
             return;
209 209
         }
210 210
 
211
-		echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ), $invoice ) ) . '</h3>' . PHP_EOL;
211
+        echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ), $invoice ) ) . '</h3>' . PHP_EOL;
212
+
213
+        echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
214
+
215
+        foreach ( $bank_info as $key => $data ) {
216
+            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;
217
+        }
218
+
219
+        echo '</table>';
220
+
221
+    }
222
+
223
+    /**
224
+     * Get country locale if localized.
225
+     *
226
+     * @return array
227
+     */
228
+    public function get_country_locale() {
229
+
230
+        if ( empty( $this->locale ) ) {
231
+
232
+            // Locale information to be used - only those that are not 'Sort Code'.
233
+            $this->locale = apply_filters(
234
+                'getpaid_get_bank_transfer_locale',
235
+                array(
236
+                    'AU' => array(
237
+                        'sortcode' => array(
238
+                            'label' => __( 'BSB', 'invoicing' ),
239
+                        ),
240
+                    ),
241
+                    'CA' => array(
242
+                        'sortcode' => array(
243
+                            'label' => __( 'Bank transit number', 'invoicing' ),
244
+                        ),
245
+                    ),
246
+                    'IN' => array(
247
+                        'sortcode' => array(
248
+                            'label' => __( 'IFSC', 'invoicing' ),
249
+                        ),
250
+                    ),
251
+                    'IT' => array(
252
+                        'sortcode' => array(
253
+                            'label' => __( 'Branch sort', 'invoicing' ),
254
+                        ),
255
+                    ),
256
+                    'NZ' => array(
257
+                        'sortcode' => array(
258
+                            'label' => __( 'Bank code', 'invoicing' ),
259
+                        ),
260
+                    ),
261
+                    'SE' => array(
262
+                        'sortcode' => array(
263
+                            'label' => __( 'Bank code', 'invoicing' ),
264
+                        ),
265
+                    ),
266
+                    'US' => array(
267
+                        'sortcode' => array(
268
+                            'label' => __( 'Routing number', 'invoicing' ),
269
+                        ),
270
+                    ),
271
+                    'ZA' => array(
272
+                        'sortcode' => array(
273
+                            'label' => __( 'Branch code', 'invoicing' ),
274
+                        ),
275
+                    ),
276
+                )
277
+            );
278
+
279
+        }
280
+
281
+        return $this->locale;
282
+
283
+    }
284
+
285
+    /**
286
+     * Filters the gateway settings.
287
+     *
288
+     * @param array $admin_settings
289
+     */
290
+    public function admin_settings( $admin_settings ) {
291
+        $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' );
292
+        $admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
293
+
294
+        $_settings = array();
295
+
296
+        foreach ( $admin_settings as $key => $setting ) {
297
+            $_settings[ $key ] = $setting;
298
+
299
+            if ( $key == 'bank_transfer_active' ) {
300
+                // Enable/disable subscriptions setting.
301
+                $_settings['bank_transfer_no_subscription'] = array(
302
+                    'id' => 'bank_transfer_no_subscription',
303
+                    'type' => 'checkbox',
304
+                    'name' => __( 'Disable Subscriptions', 'invoicing' ),
305
+                    'desc' => __( 'Tick to disable support for recurring items.', 'invoicing' ),
306
+                    'std' => 0
307
+                );
308
+            }
309
+        }
310
+
311
+        $admin_settings = $_settings;
312
+
313
+        $locale  = $this->get_country_locale();
314
+
315
+        // Get sortcode label in the $locale array and use appropriate one.
316
+        $country  = wpinv_default_billing_country();
317
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
318
+
319
+        $admin_settings['bank_transfer_ac_name'] = array(
320
+            'type' => 'text',
321
+            'id'   => 'bank_transfer_ac_name',
322
+            'name' => __( 'Account Name', 'invoicing' ),
323
+        );
324
+
325
+        $admin_settings['bank_transfer_ac_no'] = array(
326
+            'type' => 'text',
327
+            'id'   => 'bank_transfer_ac_no',
328
+            'name' => __( 'Account Number', 'invoicing' ),
329
+        );
330
+
331
+        $admin_settings['bank_transfer_bank_name'] = array(
332
+            'type' => 'text',
333
+            'id'   => 'bank_transfer_bank_name',
334
+            'name' => __( 'Bank Name', 'invoicing' ),
335
+        );
212 336
 
213
-		echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
337
+        $admin_settings['bank_transfer_ifsc'] = array(
338
+            'type' => 'text',
339
+            'id'   => 'bank_transfer_ifsc',
340
+            'name' => __( 'IFSC Code', 'invoicing' ),
341
+        );
342
+
343
+        $admin_settings['bank_transfer_iban'] = array(
344
+            'type' => 'text',
345
+            'id'   => 'bank_transfer_iban',
346
+            'name' => __( 'IBAN', 'invoicing' ),
347
+        );
348
+
349
+        $admin_settings['bank_transfer_bic'] = array(
350
+            'type' => 'text',
351
+            'id'   => 'bank_transfer_bic',
352
+            'name' => __( 'BIC/Swift Code', 'invoicing' ),
353
+        );
214 354
 
215
-		foreach ( $bank_info as $key => $data ) {
216
-			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;
217
-		}
355
+        $admin_settings['bank_transfer_sort_code'] = array(
356
+            'type' => 'text',
357
+            'id'   => 'bank_transfer_sort_code',
358
+            'name' => $sortcode,
359
+        );
218 360
 
219
-		echo '</table>';
361
+        $admin_settings['bank_transfer_info'] = array(
362
+            'id'   => 'bank_transfer_info',
363
+            'name' => __( 'Instructions', 'invoicing' ),
364
+            'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
365
+            'type' => 'textarea',
366
+            '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' ),
367
+            'cols' => 50,
368
+            'rows' => 5,
369
+        );
220 370
 
371
+        return $admin_settings;
221 372
     }
222 373
 
223 374
     /**
224
-	 * Get country locale if localized.
225
-	 *
226
-	 * @return array
227
-	 */
228
-	public function get_country_locale() {
229
-
230
-		if ( empty( $this->locale ) ) {
231
-
232
-			// Locale information to be used - only those that are not 'Sort Code'.
233
-			$this->locale = apply_filters(
234
-				'getpaid_get_bank_transfer_locale',
235
-				array(
236
-					'AU' => array(
237
-						'sortcode' => array(
238
-							'label' => __( 'BSB', 'invoicing' ),
239
-						),
240
-					),
241
-					'CA' => array(
242
-						'sortcode' => array(
243
-							'label' => __( 'Bank transit number', 'invoicing' ),
244
-						),
245
-					),
246
-					'IN' => array(
247
-						'sortcode' => array(
248
-							'label' => __( 'IFSC', 'invoicing' ),
249
-						),
250
-					),
251
-					'IT' => array(
252
-						'sortcode' => array(
253
-							'label' => __( 'Branch sort', 'invoicing' ),
254
-						),
255
-					),
256
-					'NZ' => array(
257
-						'sortcode' => array(
258
-							'label' => __( 'Bank code', 'invoicing' ),
259
-						),
260
-					),
261
-					'SE' => array(
262
-						'sortcode' => array(
263
-							'label' => __( 'Bank code', 'invoicing' ),
264
-						),
265
-					),
266
-					'US' => array(
267
-						'sortcode' => array(
268
-							'label' => __( 'Routing number', 'invoicing' ),
269
-						),
270
-					),
271
-					'ZA' => array(
272
-						'sortcode' => array(
273
-							'label' => __( 'Branch code', 'invoicing' ),
274
-						),
275
-					),
276
-				)
277
-			);
278
-
279
-		}
280
-
281
-		return $this->locale;
282
-
283
-	}
284
-
285
-	/**
286
-	 * Filters the gateway settings.
287
-	 *
288
-	 * @param array $admin_settings
289
-	 */
290
-	public function admin_settings( $admin_settings ) {
291
-		$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' );
292
-		$admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
293
-
294
-		$_settings = array();
295
-
296
-		foreach ( $admin_settings as $key => $setting ) {
297
-			$_settings[ $key ] = $setting;
298
-
299
-			if ( $key == 'bank_transfer_active' ) {
300
-				// Enable/disable subscriptions setting.
301
-				$_settings['bank_transfer_no_subscription'] = array(
302
-					'id' => 'bank_transfer_no_subscription',
303
-					'type' => 'checkbox',
304
-					'name' => __( 'Disable Subscriptions', 'invoicing' ),
305
-					'desc' => __( 'Tick to disable support for recurring items.', 'invoicing' ),
306
-					'std' => 0
307
-				);
308
-			}
309
-		}
310
-
311
-		$admin_settings = $_settings;
312
-
313
-		$locale  = $this->get_country_locale();
314
-
315
-		// Get sortcode label in the $locale array and use appropriate one.
316
-		$country  = wpinv_default_billing_country();
317
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
318
-
319
-		$admin_settings['bank_transfer_ac_name'] = array(
320
-			'type' => 'text',
321
-			'id'   => 'bank_transfer_ac_name',
322
-			'name' => __( 'Account Name', 'invoicing' ),
323
-		);
324
-
325
-		$admin_settings['bank_transfer_ac_no'] = array(
326
-			'type' => 'text',
327
-			'id'   => 'bank_transfer_ac_no',
328
-			'name' => __( 'Account Number', 'invoicing' ),
329
-		);
330
-
331
-		$admin_settings['bank_transfer_bank_name'] = array(
332
-			'type' => 'text',
333
-			'id'   => 'bank_transfer_bank_name',
334
-			'name' => __( 'Bank Name', 'invoicing' ),
335
-		);
336
-
337
-		$admin_settings['bank_transfer_ifsc'] = array(
338
-			'type' => 'text',
339
-			'id'   => 'bank_transfer_ifsc',
340
-			'name' => __( 'IFSC Code', 'invoicing' ),
341
-		);
342
-
343
-		$admin_settings['bank_transfer_iban'] = array(
344
-			'type' => 'text',
345
-			'id'   => 'bank_transfer_iban',
346
-			'name' => __( 'IBAN', 'invoicing' ),
347
-		);
348
-
349
-		$admin_settings['bank_transfer_bic'] = array(
350
-			'type' => 'text',
351
-			'id'   => 'bank_transfer_bic',
352
-			'name' => __( 'BIC/Swift Code', 'invoicing' ),
353
-		);
354
-
355
-		$admin_settings['bank_transfer_sort_code'] = array(
356
-			'type' => 'text',
357
-			'id'   => 'bank_transfer_sort_code',
358
-			'name' => $sortcode,
359
-		);
360
-
361
-		$admin_settings['bank_transfer_info'] = array(
362
-			'id'   => 'bank_transfer_info',
363
-			'name' => __( 'Instructions', 'invoicing' ),
364
-			'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
365
-			'type' => 'textarea',
366
-			'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' ),
367
-			'cols' => 50,
368
-			'rows' => 5,
369
-		);
370
-
371
-		return $admin_settings;
372
-	}
373
-
374
-	/**
375
-	 * Processes invoice addons.
376
-	 *
377
-	 * @param WPInv_Invoice $invoice
378
-	 * @param GetPaid_Form_Item[] $items
379
-	 * @return WPInv_Invoice
380
-	 */
381
-	public function process_addons( $invoice, $items ) {
375
+     * Processes invoice addons.
376
+     *
377
+     * @param WPInv_Invoice $invoice
378
+     * @param GetPaid_Form_Item[] $items
379
+     * @return WPInv_Invoice
380
+     */
381
+    public function process_addons( $invoice, $items ) {
382 382
 
383 383
         foreach ( $items as $item ) {
384 384
             $invoice->add_item( $item );
@@ -386,98 +386,98 @@  discard block
 block discarded – undo
386 386
 
387 387
         $invoice->recalculate_total();
388 388
         $invoice->save();
389
-	}
390
-
391
-	/**
392
-	 * (Maybe) renews a bank transfer subscription profile.
393
-	 *
394
-	 *
395
-	 * @param WPInv_Subscription $subscription
396
-	 */
397
-	public function maybe_renew_subscription( $subscription, $parent_invoice ) {
398
-		// Ensure its our subscription && it's active.
399
-		if ( ! empty( $parent_invoice ) && $this->id === $parent_invoice->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
400
-			add_filter( 'getpaid_invoice_notifications_is_payment_form_invoice', array( $this, 'force_is_payment_form_invoice' ), 10, 2 );
401
-
402
-			$invoice = $subscription->create_payment();
403
-
404
-			if ( ! empty( $invoice ) ) {
405
-				$is_logged_in = is_user_logged_in();
406
-
407
-				// Cron run.
408
-				if ( ! $is_logged_in ) {
409
-					$note = wp_sprintf( __( 'Renewal %1$s created with the status "%2$s".', 'invoicing' ), $invoice->get_invoice_quote_type(), wpinv_status_nicename( $invoice->get_status(), $invoice ) );
410
-
411
-					$invoice->add_note( $note, false, $is_logged_in, ! $is_logged_in );
412
-				}
413
-			}
414
-
415
-			remove_filter( 'getpaid_invoice_notifications_is_payment_form_invoice', array( $this, 'force_is_payment_form_invoice' ), 10, 2 );
416
-		}
417
-	}
418
-
419
-	/**
420
-	 * Process a bank transfer payment.
421
-	 *
422
-	 *
389
+    }
390
+
391
+    /**
392
+     * (Maybe) renews a bank transfer subscription profile.
393
+     *
394
+     *
395
+     * @param WPInv_Subscription $subscription
396
+     */
397
+    public function maybe_renew_subscription( $subscription, $parent_invoice ) {
398
+        // Ensure its our subscription && it's active.
399
+        if ( ! empty( $parent_invoice ) && $this->id === $parent_invoice->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
400
+            add_filter( 'getpaid_invoice_notifications_is_payment_form_invoice', array( $this, 'force_is_payment_form_invoice' ), 10, 2 );
401
+
402
+            $invoice = $subscription->create_payment();
403
+
404
+            if ( ! empty( $invoice ) ) {
405
+                $is_logged_in = is_user_logged_in();
406
+
407
+                // Cron run.
408
+                if ( ! $is_logged_in ) {
409
+                    $note = wp_sprintf( __( 'Renewal %1$s created with the status "%2$s".', 'invoicing' ), $invoice->get_invoice_quote_type(), wpinv_status_nicename( $invoice->get_status(), $invoice ) );
410
+
411
+                    $invoice->add_note( $note, false, $is_logged_in, ! $is_logged_in );
412
+                }
413
+            }
414
+
415
+            remove_filter( 'getpaid_invoice_notifications_is_payment_form_invoice', array( $this, 'force_is_payment_form_invoice' ), 10, 2 );
416
+        }
417
+    }
418
+
419
+    /**
420
+     * Process a bank transfer payment.
421
+     *
422
+     *
423 423
      * @param WPInv_Invoice $invoice
424
-	 */
425
-	public function invoice_paid( $invoice ) {
426
-
427
-		// Abort if not paid by bank transfer.
428
-		if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) {
429
-			return;
430
-		}
431
-
432
-		// Is it a parent payment?
433
-		if ( 0 == $invoice->get_parent_id() ) {
434
-
435
-			// (Maybe) activate subscriptions.
436
-			$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
437
-
438
-			if ( ! empty( $subscriptions ) ) {
439
-				$subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
440
-
441
-				foreach ( $subscriptions as $subscription ) {
442
-					if ( $subscription->exists() ) {
443
-						$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
444
-						$expiry   = gmdate( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
445
-
446
-						$subscription->set_next_renewal_date( $expiry );
447
-						$subscription->set_date_created( current_time( 'mysql' ) );
448
-						$subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() );
449
-						$subscription->activate();
450
-					}
451
-				}
452
-			}
453
-		} else {
454
-
455
-			$subscription = getpaid_get_subscription( $invoice->get_subscription_id() );
456
-
457
-			// Renew the subscription.
458
-			if ( $subscription && $subscription->exists() ) {
459
-				$subscription->add_payment( array(), $invoice );
460
-				$subscription->renew( strtotime( $invoice->get_date_created() ) );
461
-			}
462
-		}
424
+     */
425
+    public function invoice_paid( $invoice ) {
426
+
427
+        // Abort if not paid by bank transfer.
428
+        if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) {
429
+            return;
430
+        }
431
+
432
+        // Is it a parent payment?
433
+        if ( 0 == $invoice->get_parent_id() ) {
434
+
435
+            // (Maybe) activate subscriptions.
436
+            $subscriptions = getpaid_get_invoice_subscriptions( $invoice );
437
+
438
+            if ( ! empty( $subscriptions ) ) {
439
+                $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
440
+
441
+                foreach ( $subscriptions as $subscription ) {
442
+                    if ( $subscription->exists() ) {
443
+                        $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
444
+                        $expiry   = gmdate( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
445
+
446
+                        $subscription->set_next_renewal_date( $expiry );
447
+                        $subscription->set_date_created( current_time( 'mysql' ) );
448
+                        $subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() );
449
+                        $subscription->activate();
450
+                    }
451
+                }
452
+            }
453
+        } else {
454
+
455
+            $subscription = getpaid_get_subscription( $invoice->get_subscription_id() );
456
+
457
+            // Renew the subscription.
458
+            if ( $subscription && $subscription->exists() ) {
459
+                $subscription->add_payment( array(), $invoice );
460
+                $subscription->renew( strtotime( $invoice->get_date_created() ) );
461
+            }
462
+        }
463 463
 
464 464
     }
465 465
 
466
-	/**
467
-	 * Force created from payment false to allow email for auto renewal generation invoice.
468
-	 *
469
-	 * @since 2.8.11
470
-	 *
471
-	 * @param bool $is_payment_form_invoice True when invoice created via payment form else false.
472
-	 * @param int  $invoice Invoice ID.
473
-	 * @return bool True when invoice created via payment form else false.
474
-	 */
475
-	public function force_is_payment_form_invoice( $is_payment_form_invoice, $invoice ) {
476
-		if ( $is_payment_form_invoice ) {
477
-			$is_payment_form_invoice = false;
478
-		}
479
-
480
-		return $is_payment_form_invoice;
481
-	}
466
+    /**
467
+     * Force created from payment false to allow email for auto renewal generation invoice.
468
+     *
469
+     * @since 2.8.11
470
+     *
471
+     * @param bool $is_payment_form_invoice True when invoice created via payment form else false.
472
+     * @param int  $invoice Invoice ID.
473
+     * @return bool True when invoice created via payment form else false.
474
+     */
475
+    public function force_is_payment_form_invoice( $is_payment_form_invoice, $invoice ) {
476
+        if ( $is_payment_form_invoice ) {
477
+            $is_payment_form_invoice = false;
478
+        }
479
+
480
+        return $is_payment_form_invoice;
481
+    }
482 482
 
483 483
 }
Please login to merge, or discard this patch.
Spacing   +109 added lines, -109 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.
@@ -56,21 +56,21 @@  discard block
 block discarded – undo
56 56
 	public function __construct() {
57 57
         parent::__construct();
58 58
 
59
-        $this->title                = __( 'Direct bank transfer', 'invoicing' );
60
-        $this->method_title         = __( 'Bank transfer', 'invoicing' );
61
-        $this->checkout_button_text = __( 'Proceed', 'invoicing' );
62
-        $this->instructions         = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) );
63
-
64
-		add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
65
-		add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
66
-		add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
67
-		add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
68
-		add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ), 12, 2 );
69
-		add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 );
70
-
71
-		add_filter( 'wpinv_' . $this->id . '_support_subscription', array( $this, 'supports_subscription' ), 20, 1 );
72
-		add_filter( 'getpaid_' . $this->id . '_support_subscription', array( $this, 'supports_subscription' ), 20, 1 );
73
-		add_filter( 'getpaid_' . $this->id . '_supports_subscription', array( $this, 'supports_subscription' ), 20, 1 );
59
+        $this->title                = __('Direct bank transfer', 'invoicing');
60
+        $this->method_title         = __('Bank transfer', 'invoicing');
61
+        $this->checkout_button_text = __('Proceed', 'invoicing');
62
+        $this->instructions         = apply_filters('wpinv_bank_instructions', $this->get_option('info'));
63
+
64
+		add_action('wpinv_receipt_end', array($this, 'thankyou_page'));
65
+		add_action('getpaid_invoice_line_items', array($this, 'thankyou_page'), 40);
66
+		add_action('wpinv_pdf_content_billing', array($this, 'thankyou_page'), 11);
67
+		add_action('wpinv_email_invoice_details', array($this, 'email_instructions'), 10, 3);
68
+		add_action('getpaid_should_renew_subscription', array($this, 'maybe_renew_subscription'), 12, 2);
69
+		add_action('getpaid_invoice_status_publish', array($this, 'invoice_paid'), 20);
70
+
71
+		add_filter('wpinv_' . $this->id . '_support_subscription', array($this, 'supports_subscription'), 20, 1);
72
+		add_filter('getpaid_' . $this->id . '_support_subscription', array($this, 'supports_subscription'), 20, 1);
73
+		add_filter('getpaid_' . $this->id . '_supports_subscription', array($this, 'supports_subscription'), 20, 1);
74 74
 	}
75 75
 
76 76
 	/**
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 	 * @param bool $supports True if supports else False.
82 82
 	 * @return bool True if supports else False.
83 83
 	 */
84
-	public function supports_subscription( $supports ) {
85
-		if ( $supports && (int) $this->get_option( 'no_subscription' ) ) {
84
+	public function supports_subscription($supports) {
85
+		if ($supports && (int) $this->get_option('no_subscription')) {
86 86
 			$supports = false;
87 87
 		}
88 88
 
@@ -97,23 +97,23 @@  discard block
 block discarded – undo
97 97
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
98 98
 	 * @return array
99 99
 	 */
100
-	public function process_payment( $invoice, $submission_data, $submission ) {
100
+	public function process_payment($invoice, $submission_data, $submission) {
101 101
 
102 102
         // Add a transaction id.
103
-        $invoice->set_transaction_id( $invoice->generate_key( 'bt_' ) );
103
+        $invoice->set_transaction_id($invoice->generate_key('bt_'));
104 104
 
105 105
         // Set it as pending payment.
106
-        if ( ! $invoice->needs_payment() ) {
106
+        if (!$invoice->needs_payment()) {
107 107
             $invoice->mark_paid();
108
-        } elseif ( ! $invoice->is_paid() ) {
109
-            $invoice->set_status( 'wpi-onhold' );
108
+        } elseif (!$invoice->is_paid()) {
109
+            $invoice->set_status('wpi-onhold');
110 110
         }
111 111
 
112 112
         // Save it.
113 113
         $invoice->save();
114 114
 
115 115
         // Send to the success page.
116
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
116
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
117 117
 
118 118
     }
119 119
 
@@ -122,17 +122,17 @@  discard block
 block discarded – undo
122 122
 	 *
123 123
 	 * @param WPInv_Invoice $invoice Invoice.
124 124
 	 */
125
-	public function thankyou_page( $invoice ) {
125
+	public function thankyou_page($invoice) {
126 126
 
127
-        if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
127
+        if ('bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) {
128 128
 
129 129
 			echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
130 130
 
131
-            if ( ! empty( $this->instructions ) ) {
132
-                echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) );
131
+            if (!empty($this->instructions)) {
132
+                echo wp_kses_post(wpautop(wptexturize($this->instructions)));
133 133
 			}
134 134
 
135
-			$this->bank_details( $invoice );
135
+			$this->bank_details($invoice);
136 136
 
137 137
 			echo '</div>';
138 138
 
@@ -147,17 +147,17 @@  discard block
 block discarded – undo
147 147
 	 * @param string     $email_type Email format: plain text or HTML.
148 148
 	 * @param bool     $sent_to_admin Sent to admin.
149 149
 	 */
150
-	public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
150
+	public function email_instructions($invoice, $email_type, $sent_to_admin) {
151 151
 
152
-		if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
152
+		if (!$sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) {
153 153
 
154 154
 			echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
155 155
 
156
-			if ( $this->instructions ) {
157
-				echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
156
+			if ($this->instructions) {
157
+				echo wp_kses_post(wpautop(wptexturize($this->instructions)) . PHP_EOL);
158 158
             }
159 159
 
160
-			$this->bank_details( $invoice );
160
+			$this->bank_details($invoice);
161 161
 
162 162
 			echo '</div>';
163 163
 
@@ -170,50 +170,50 @@  discard block
 block discarded – undo
170 170
 	 *
171 171
 	 * @param WPInv_Invoice $invoice Invoice.
172 172
 	 */
173
-	protected function bank_details( $invoice ) {
173
+	protected function bank_details($invoice) {
174 174
 
175 175
 		// Get the invoice country and country $locale.
176 176
 		$country = $invoice->get_country();
177 177
 		$locale  = $this->get_country_locale();
178 178
 
179 179
 		// Get shortcode label in the $locale array and use appropriate one.
180
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
180
+		$sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing');
181 181
 
182 182
         $bank_fields = array(
183
-            'ac_name'   => __( 'Account Name', 'invoicing' ),
184
-            'ac_no'     => __( 'Account Number', 'invoicing' ),
185
-            'bank_name' => __( 'Bank Name', 'invoicing' ),
186
-            'ifsc'      => __( 'IFSC code', 'invoicing' ),
187
-            'iban'      => __( 'IBAN', 'invoicing' ),
188
-            'bic'       => __( 'BIC/Swift code', 'invoicing' ),
183
+            'ac_name'   => __('Account Name', 'invoicing'),
184
+            'ac_no'     => __('Account Number', 'invoicing'),
185
+            'bank_name' => __('Bank Name', 'invoicing'),
186
+            'ifsc'      => __('IFSC code', 'invoicing'),
187
+            'iban'      => __('IBAN', 'invoicing'),
188
+            'bic'       => __('BIC/Swift code', 'invoicing'),
189 189
             'sort_code' => $sortcode,
190 190
         );
191 191
 
192 192
         $bank_info = array();
193 193
 
194
-        foreach ( $bank_fields as $field => $label ) {
195
-            $value = $this->get_option( $field );
194
+        foreach ($bank_fields as $field => $label) {
195
+            $value = $this->get_option($field);
196 196
 
197
-            if ( ! empty( $value ) ) {
198
-                $bank_info[ $field ] = array(
197
+            if (!empty($value)) {
198
+                $bank_info[$field] = array(
199 199
 					'label' => $label,
200 200
 					'value' => $value,
201 201
 				);
202 202
             }
203 203
 		}
204 204
 
205
-        $bank_info = apply_filters( 'wpinv_bank_info', $bank_info, $invoice );
205
+        $bank_info = apply_filters('wpinv_bank_info', $bank_info, $invoice);
206 206
 
207
-        if ( empty( $bank_info ) ) {
207
+        if (empty($bank_info)) {
208 208
             return;
209 209
         }
210 210
 
211
-		echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ), $invoice ) ) . '</h3>' . PHP_EOL;
211
+		echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html(apply_filters('wpinv_receipt_bank_details_title', __('Bank Details', 'invoicing'), $invoice)) . '</h3>' . PHP_EOL;
212 212
 
213 213
 		echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
214 214
 
215
-		foreach ( $bank_info as $key => $data ) {
216
-			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;
215
+		foreach ($bank_info as $key => $data) {
216
+			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;
217 217
 		}
218 218
 
219 219
 		echo '</table>';
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	 */
228 228
 	public function get_country_locale() {
229 229
 
230
-		if ( empty( $this->locale ) ) {
230
+		if (empty($this->locale)) {
231 231
 
232 232
 			// Locale information to be used - only those that are not 'Sort Code'.
233 233
 			$this->locale = apply_filters(
@@ -235,42 +235,42 @@  discard block
 block discarded – undo
235 235
 				array(
236 236
 					'AU' => array(
237 237
 						'sortcode' => array(
238
-							'label' => __( 'BSB', 'invoicing' ),
238
+							'label' => __('BSB', 'invoicing'),
239 239
 						),
240 240
 					),
241 241
 					'CA' => array(
242 242
 						'sortcode' => array(
243
-							'label' => __( 'Bank transit number', 'invoicing' ),
243
+							'label' => __('Bank transit number', 'invoicing'),
244 244
 						),
245 245
 					),
246 246
 					'IN' => array(
247 247
 						'sortcode' => array(
248
-							'label' => __( 'IFSC', 'invoicing' ),
248
+							'label' => __('IFSC', 'invoicing'),
249 249
 						),
250 250
 					),
251 251
 					'IT' => array(
252 252
 						'sortcode' => array(
253
-							'label' => __( 'Branch sort', 'invoicing' ),
253
+							'label' => __('Branch sort', 'invoicing'),
254 254
 						),
255 255
 					),
256 256
 					'NZ' => array(
257 257
 						'sortcode' => array(
258
-							'label' => __( 'Bank code', 'invoicing' ),
258
+							'label' => __('Bank code', 'invoicing'),
259 259
 						),
260 260
 					),
261 261
 					'SE' => array(
262 262
 						'sortcode' => array(
263
-							'label' => __( 'Bank code', 'invoicing' ),
263
+							'label' => __('Bank code', 'invoicing'),
264 264
 						),
265 265
 					),
266 266
 					'US' => array(
267 267
 						'sortcode' => array(
268
-							'label' => __( 'Routing number', 'invoicing' ),
268
+							'label' => __('Routing number', 'invoicing'),
269 269
 						),
270 270
 					),
271 271
 					'ZA' => array(
272 272
 						'sortcode' => array(
273
-							'label' => __( 'Branch code', 'invoicing' ),
273
+							'label' => __('Branch code', 'invoicing'),
274 274
 						),
275 275
 					),
276 276
 				)
@@ -287,22 +287,22 @@  discard block
 block discarded – undo
287 287
 	 *
288 288
 	 * @param array $admin_settings
289 289
 	 */
290
-	public function admin_settings( $admin_settings ) {
291
-		$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' );
292
-		$admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
290
+	public function admin_settings($admin_settings) {
291
+		$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');
292
+		$admin_settings['bank_transfer_active']['desc'] = __('Enable bank transfer', 'invoicing');
293 293
 
294 294
 		$_settings = array();
295 295
 
296
-		foreach ( $admin_settings as $key => $setting ) {
297
-			$_settings[ $key ] = $setting;
296
+		foreach ($admin_settings as $key => $setting) {
297
+			$_settings[$key] = $setting;
298 298
 
299
-			if ( $key == 'bank_transfer_active' ) {
299
+			if ($key == 'bank_transfer_active') {
300 300
 				// Enable/disable subscriptions setting.
301 301
 				$_settings['bank_transfer_no_subscription'] = array(
302 302
 					'id' => 'bank_transfer_no_subscription',
303 303
 					'type' => 'checkbox',
304
-					'name' => __( 'Disable Subscriptions', 'invoicing' ),
305
-					'desc' => __( 'Tick to disable support for recurring items.', 'invoicing' ),
304
+					'name' => __('Disable Subscriptions', 'invoicing'),
305
+					'desc' => __('Tick to disable support for recurring items.', 'invoicing'),
306 306
 					'std' => 0
307 307
 				);
308 308
 			}
@@ -310,46 +310,46 @@  discard block
 block discarded – undo
310 310
 
311 311
 		$admin_settings = $_settings;
312 312
 
313
-		$locale  = $this->get_country_locale();
313
+		$locale = $this->get_country_locale();
314 314
 
315 315
 		// Get sortcode label in the $locale array and use appropriate one.
316 316
 		$country  = wpinv_default_billing_country();
317
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
317
+		$sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing');
318 318
 
319 319
 		$admin_settings['bank_transfer_ac_name'] = array(
320 320
 			'type' => 'text',
321 321
 			'id'   => 'bank_transfer_ac_name',
322
-			'name' => __( 'Account Name', 'invoicing' ),
322
+			'name' => __('Account Name', 'invoicing'),
323 323
 		);
324 324
 
325 325
 		$admin_settings['bank_transfer_ac_no'] = array(
326 326
 			'type' => 'text',
327 327
 			'id'   => 'bank_transfer_ac_no',
328
-			'name' => __( 'Account Number', 'invoicing' ),
328
+			'name' => __('Account Number', 'invoicing'),
329 329
 		);
330 330
 
331 331
 		$admin_settings['bank_transfer_bank_name'] = array(
332 332
 			'type' => 'text',
333 333
 			'id'   => 'bank_transfer_bank_name',
334
-			'name' => __( 'Bank Name', 'invoicing' ),
334
+			'name' => __('Bank Name', 'invoicing'),
335 335
 		);
336 336
 
337 337
 		$admin_settings['bank_transfer_ifsc'] = array(
338 338
 			'type' => 'text',
339 339
 			'id'   => 'bank_transfer_ifsc',
340
-			'name' => __( 'IFSC Code', 'invoicing' ),
340
+			'name' => __('IFSC Code', 'invoicing'),
341 341
 		);
342 342
 
343 343
 		$admin_settings['bank_transfer_iban'] = array(
344 344
 			'type' => 'text',
345 345
 			'id'   => 'bank_transfer_iban',
346
-			'name' => __( 'IBAN', 'invoicing' ),
346
+			'name' => __('IBAN', 'invoicing'),
347 347
 		);
348 348
 
349 349
 		$admin_settings['bank_transfer_bic'] = array(
350 350
 			'type' => 'text',
351 351
 			'id'   => 'bank_transfer_bic',
352
-			'name' => __( 'BIC/Swift Code', 'invoicing' ),
352
+			'name' => __('BIC/Swift Code', 'invoicing'),
353 353
 		);
354 354
 
355 355
 		$admin_settings['bank_transfer_sort_code'] = array(
@@ -360,10 +360,10 @@  discard block
 block discarded – undo
360 360
 
361 361
 		$admin_settings['bank_transfer_info'] = array(
362 362
 			'id'   => 'bank_transfer_info',
363
-			'name' => __( 'Instructions', 'invoicing' ),
364
-			'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
363
+			'name' => __('Instructions', 'invoicing'),
364
+			'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'),
365 365
 			'type' => 'textarea',
366
-			'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' ),
366
+			'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'),
367 367
 			'cols' => 50,
368 368
 			'rows' => 5,
369 369
 		);
@@ -378,10 +378,10 @@  discard block
 block discarded – undo
378 378
 	 * @param GetPaid_Form_Item[] $items
379 379
 	 * @return WPInv_Invoice
380 380
 	 */
381
-	public function process_addons( $invoice, $items ) {
381
+	public function process_addons($invoice, $items) {
382 382
 
383
-        foreach ( $items as $item ) {
384
-            $invoice->add_item( $item );
383
+        foreach ($items as $item) {
384
+            $invoice->add_item($item);
385 385
         }
386 386
 
387 387
         $invoice->recalculate_total();
@@ -394,25 +394,25 @@  discard block
 block discarded – undo
394 394
 	 *
395 395
 	 * @param WPInv_Subscription $subscription
396 396
 	 */
397
-	public function maybe_renew_subscription( $subscription, $parent_invoice ) {
397
+	public function maybe_renew_subscription($subscription, $parent_invoice) {
398 398
 		// Ensure its our subscription && it's active.
399
-		if ( ! empty( $parent_invoice ) && $this->id === $parent_invoice->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
400
-			add_filter( 'getpaid_invoice_notifications_is_payment_form_invoice', array( $this, 'force_is_payment_form_invoice' ), 10, 2 );
399
+		if (!empty($parent_invoice) && $this->id === $parent_invoice->get_gateway() && $subscription->has_status('active trialling')) {
400
+			add_filter('getpaid_invoice_notifications_is_payment_form_invoice', array($this, 'force_is_payment_form_invoice'), 10, 2);
401 401
 
402 402
 			$invoice = $subscription->create_payment();
403 403
 
404
-			if ( ! empty( $invoice ) ) {
404
+			if (!empty($invoice)) {
405 405
 				$is_logged_in = is_user_logged_in();
406 406
 
407 407
 				// Cron run.
408
-				if ( ! $is_logged_in ) {
409
-					$note = wp_sprintf( __( 'Renewal %1$s created with the status "%2$s".', 'invoicing' ), $invoice->get_invoice_quote_type(), wpinv_status_nicename( $invoice->get_status(), $invoice ) );
408
+				if (!$is_logged_in) {
409
+					$note = wp_sprintf(__('Renewal %1$s created with the status "%2$s".', 'invoicing'), $invoice->get_invoice_quote_type(), wpinv_status_nicename($invoice->get_status(), $invoice));
410 410
 
411
-					$invoice->add_note( $note, false, $is_logged_in, ! $is_logged_in );
411
+					$invoice->add_note($note, false, $is_logged_in, !$is_logged_in);
412 412
 				}
413 413
 			}
414 414
 
415
-			remove_filter( 'getpaid_invoice_notifications_is_payment_form_invoice', array( $this, 'force_is_payment_form_invoice' ), 10, 2 );
415
+			remove_filter('getpaid_invoice_notifications_is_payment_form_invoice', array($this, 'force_is_payment_form_invoice'), 10, 2);
416 416
 		}
417 417
 	}
418 418
 
@@ -422,42 +422,42 @@  discard block
 block discarded – undo
422 422
 	 *
423 423
      * @param WPInv_Invoice $invoice
424 424
 	 */
425
-	public function invoice_paid( $invoice ) {
425
+	public function invoice_paid($invoice) {
426 426
 
427 427
 		// Abort if not paid by bank transfer.
428
-		if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) {
428
+		if ($this->id !== $invoice->get_gateway() || !$invoice->is_recurring()) {
429 429
 			return;
430 430
 		}
431 431
 
432 432
 		// Is it a parent payment?
433
-		if ( 0 == $invoice->get_parent_id() ) {
433
+		if (0 == $invoice->get_parent_id()) {
434 434
 
435 435
 			// (Maybe) activate subscriptions.
436
-			$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
436
+			$subscriptions = getpaid_get_invoice_subscriptions($invoice);
437 437
 
438
-			if ( ! empty( $subscriptions ) ) {
439
-				$subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
438
+			if (!empty($subscriptions)) {
439
+				$subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions);
440 440
 
441
-				foreach ( $subscriptions as $subscription ) {
442
-					if ( $subscription->exists() ) {
443
-						$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
444
-						$expiry   = gmdate( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
441
+				foreach ($subscriptions as $subscription) {
442
+					if ($subscription->exists()) {
443
+						$duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created());
444
+						$expiry   = gmdate('Y-m-d H:i:s', (current_time('timestamp') + $duration));
445 445
 
446
-						$subscription->set_next_renewal_date( $expiry );
447
-						$subscription->set_date_created( current_time( 'mysql' ) );
448
-						$subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() );
446
+						$subscription->set_next_renewal_date($expiry);
447
+						$subscription->set_date_created(current_time('mysql'));
448
+						$subscription->set_profile_id('bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id());
449 449
 						$subscription->activate();
450 450
 					}
451 451
 				}
452 452
 			}
453 453
 		} else {
454 454
 
455
-			$subscription = getpaid_get_subscription( $invoice->get_subscription_id() );
455
+			$subscription = getpaid_get_subscription($invoice->get_subscription_id());
456 456
 
457 457
 			// Renew the subscription.
458
-			if ( $subscription && $subscription->exists() ) {
459
-				$subscription->add_payment( array(), $invoice );
460
-				$subscription->renew( strtotime( $invoice->get_date_created() ) );
458
+			if ($subscription && $subscription->exists()) {
459
+				$subscription->add_payment(array(), $invoice);
460
+				$subscription->renew(strtotime($invoice->get_date_created()));
461 461
 			}
462 462
 		}
463 463
 
@@ -472,8 +472,8 @@  discard block
 block discarded – undo
472 472
 	 * @param int  $invoice Invoice ID.
473 473
 	 * @return bool True when invoice created via payment form else false.
474 474
 	 */
475
-	public function force_is_payment_form_invoice( $is_payment_form_invoice, $invoice ) {
476
-		if ( $is_payment_form_invoice ) {
475
+	public function force_is_payment_form_invoice($is_payment_form_invoice, $invoice) {
476
+		if ($is_payment_form_invoice) {
477 477
 			$is_payment_form_invoice = false;
478 478
 		}
479 479
 
Please login to merge, or discard this patch.