Passed
Push — master ( fbd145...a5c159 )
by Kiran
14:08 queued 08:25
created
includes/gateways/class-getpaid-paypal-gateway.php 1 patch
Spacing   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Paypal Payment Gateway class.
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @var array
26 26
 	 */
27
-    protected $supports = array( 'subscription', 'sandbox', 'single_subscription_group', 'refunds' );
27
+    protected $supports = array('subscription', 'sandbox', 'single_subscription_group', 'refunds');
28 28
 
29 29
     /**
30 30
 	 * Payment method order.
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @var array
61 61
 	 */
62
-	public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' );
62
+	public $currencies = array('AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR');
63 63
 
64 64
     /**
65 65
 	 * URL to view a transaction.
@@ -81,22 +81,22 @@  discard block
 block discarded – undo
81 81
 	public function __construct() {
82 82
 		parent::__construct();
83 83
 
84
-        $this->title                = __( 'PayPal Standard', 'invoicing' );
85
-        $this->method_title         = __( 'PayPal Standard', 'invoicing' );
86
-        $this->checkout_button_text = __( 'Proceed to PayPal', 'invoicing' );
87
-        $this->notify_url           = wpinv_get_ipn_url( $this->id );
88
-
89
-		add_filter( 'wpinv_subscription_cancel_url', array( $this, 'filter_cancel_subscription_url' ), 10, 2 );
90
-		add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 );
91
-		add_filter( 'getpaid_get_paypal_connect_url', array( $this, 'maybe_get_connect_url' ), 10, 2 );
92
-		add_action( 'getpaid_authenticated_admin_action_connect_paypal', array( $this, 'connect_paypal' ) );
93
-		add_action( 'wpinv_paypal_connect', array( $this, 'display_connect_buttons' ) );
94
-
95
-		if ( $this->enabled ) {
96
-			add_filter( 'getpaid_paypal_sandbox_notice', array( $this, 'sandbox_notice' ) );
97
-			add_action( 'getpaid_paypal_subscription_cancelled', array( $this, 'subscription_cancelled' ) );
98
-			add_action( 'getpaid_delete_subscription', array( $this, 'subscription_cancelled' ) );
99
-			add_action( 'getpaid_refund_invoice_remotely', array( $this, 'refund_invoice' ) );
84
+        $this->title                = __('PayPal Standard', 'invoicing');
85
+        $this->method_title         = __('PayPal Standard', 'invoicing');
86
+        $this->checkout_button_text = __('Proceed to PayPal', 'invoicing');
87
+        $this->notify_url           = wpinv_get_ipn_url($this->id);
88
+
89
+		add_filter('wpinv_subscription_cancel_url', array($this, 'filter_cancel_subscription_url'), 10, 2);
90
+		add_filter('getpaid_paypal_args', array($this, 'process_subscription'), 10, 2);
91
+		add_filter('getpaid_get_paypal_connect_url', array($this, 'maybe_get_connect_url'), 10, 2);
92
+		add_action('getpaid_authenticated_admin_action_connect_paypal', array($this, 'connect_paypal'));
93
+		add_action('wpinv_paypal_connect', array($this, 'display_connect_buttons'));
94
+
95
+		if ($this->enabled) {
96
+			add_filter('getpaid_paypal_sandbox_notice', array($this, 'sandbox_notice'));
97
+			add_action('getpaid_paypal_subscription_cancelled', array($this, 'subscription_cancelled'));
98
+			add_action('getpaid_delete_subscription', array($this, 'subscription_cancelled'));
99
+			add_action('getpaid_refund_invoice_remotely', array($this, 'refund_invoice'));
100 100
 		}
101 101
     }
102 102
 
@@ -109,16 +109,16 @@  discard block
 block discarded – undo
109 109
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
110 110
 	 * @return array
111 111
 	 */
112
-	public function process_payment( $invoice, $submission_data, $submission ) {
112
+	public function process_payment($invoice, $submission_data, $submission) {
113 113
 
114 114
         // Get redirect url.
115
-        $paypal_redirect = $this->get_request_url( $invoice );
115
+        $paypal_redirect = $this->get_request_url($invoice);
116 116
 
117 117
         // Add a note about the request url.
118 118
         $invoice->add_note(
119 119
             sprintf(
120
-                __( 'Redirecting to PayPal: %s', 'invoicing' ),
121
-                esc_url( $paypal_redirect )
120
+                __('Redirecting to PayPal: %s', 'invoicing'),
121
+                esc_url($paypal_redirect)
122 122
             ),
123 123
             false,
124 124
             false,
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
         );
127 127
 
128 128
         // Redirect to PayPal
129
-        wp_redirect( $paypal_redirect );
129
+        wp_redirect($paypal_redirect);
130 130
         exit;
131 131
 
132 132
     }
@@ -137,21 +137,21 @@  discard block
 block discarded – undo
137 137
 	 * @param  WPInv_Invoice $invoice Invoice object.
138 138
 	 * @return string
139 139
 	 */
140
-	public function get_request_url( $invoice ) {
140
+	public function get_request_url($invoice) {
141 141
 
142 142
         // Endpoint for this request
143
-		$this->endpoint    = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
143
+		$this->endpoint = $this->is_sandbox($invoice) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
144 144
 
145 145
         // Retrieve paypal args.
146
-        $paypal_args       = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' );
146
+        $paypal_args = map_deep($this->get_paypal_args($invoice), 'urlencode');
147 147
 
148
-        if ( $invoice->is_recurring() ) {
148
+        if ($invoice->is_recurring()) {
149 149
             $paypal_args['bn'] = 'GetPaid_Subscribe_WPS_US';
150 150
         } else {
151 151
             $paypal_args['bn'] = 'GetPaid_ShoppingCart_WPS_US';
152 152
         }
153 153
 
154
-        return add_query_arg( $paypal_args, $this->endpoint );
154
+        return add_query_arg($paypal_args, $this->endpoint);
155 155
 
156 156
 	}
157 157
 
@@ -161,25 +161,25 @@  discard block
 block discarded – undo
161 161
 	 * @param  WPInv_Invoice $invoice Invoice object.
162 162
 	 * @return array
163 163
 	 */
164
-	protected function get_paypal_args( $invoice ) {
164
+	protected function get_paypal_args($invoice) {
165 165
 
166 166
         // Whether or not to send the line items as one item.
167
-		$force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', true, $invoice );
167
+		$force_one_line_item = apply_filters('getpaid_paypal_force_one_line_item', true, $invoice);
168 168
 
169
-		if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) {
169
+		if ($invoice->is_recurring() || (wpinv_use_taxes() && wpinv_prices_include_tax())) {
170 170
 			$force_one_line_item = true;
171 171
 		}
172 172
 
173 173
 		$paypal_args = apply_filters(
174 174
 			'getpaid_paypal_args',
175 175
 			array_merge(
176
-				$this->get_transaction_args( $invoice ),
177
-				$this->get_line_item_args( $invoice, $force_one_line_item )
176
+				$this->get_transaction_args($invoice),
177
+				$this->get_line_item_args($invoice, $force_one_line_item)
178 178
 			),
179 179
 			$invoice
180 180
 		);
181 181
 
182
-		return $this->fix_request_length( $invoice, $paypal_args );
182
+		return $this->fix_request_length($invoice, $paypal_args);
183 183
     }
184 184
 
185 185
     /**
@@ -188,9 +188,9 @@  discard block
 block discarded – undo
188 188
 	 * @param WPInv_Invoice $invoice Invoice object.
189 189
 	 * @return array
190 190
 	 */
191
-	protected function get_transaction_args( $invoice ) {
191
+	protected function get_transaction_args($invoice) {
192 192
 
193
-		$email = $this->is_sandbox( $invoice ) ? wpinv_get_option( 'paypal_sandbox_email', wpinv_get_option( 'paypal_email', '' ) ) : wpinv_get_option( 'paypal_email', '' );
193
+		$email = $this->is_sandbox($invoice) ? wpinv_get_option('paypal_sandbox_email', wpinv_get_option('paypal_email', '')) : wpinv_get_option('paypal_email', '');
194 194
 		return array(
195 195
             'cmd'           => '_cart',
196 196
             'business'      => $email,
@@ -201,16 +201,16 @@  discard block
 block discarded – undo
201 201
             'rm'            => is_ssl() ? 2 : 1,
202 202
             'upload'        => 1,
203 203
             'currency_code' => $invoice->get_currency(), // https://developer.paypal.com/docs/nvp-soap-api/currency-codes/#paypal
204
-            'return'        => esc_url_raw( $this->get_return_url( $invoice ) ),
205
-            'cancel_return' => esc_url_raw( $invoice->get_checkout_payment_url() ),
206
-            'notify_url'    => getpaid_limit_length( $this->notify_url, 255 ),
207
-            'invoice'       => getpaid_limit_length( $invoice->get_number(), 127 ),
204
+            'return'        => esc_url_raw($this->get_return_url($invoice)),
205
+            'cancel_return' => esc_url_raw($invoice->get_checkout_payment_url()),
206
+            'notify_url'    => getpaid_limit_length($this->notify_url, 255),
207
+            'invoice'       => getpaid_limit_length($invoice->get_number(), 127),
208 208
             'custom'        => $invoice->get_id(),
209
-            'first_name'    => getpaid_limit_length( $invoice->get_first_name(), 32 ),
210
-            'last_name'     => getpaid_limit_length( $invoice->get_last_name(), 64 ),
211
-            'country'       => getpaid_limit_length( $invoice->get_country(), 2 ),
212
-            'email'         => getpaid_limit_length( $invoice->get_email(), 127 ),
213
-            'cbt'           => get_bloginfo( 'name' ),
209
+            'first_name'    => getpaid_limit_length($invoice->get_first_name(), 32),
210
+            'last_name'     => getpaid_limit_length($invoice->get_last_name(), 64),
211
+            'country'       => getpaid_limit_length($invoice->get_country(), 2),
212
+            'email'         => getpaid_limit_length($invoice->get_email(), 127),
213
+            'cbt'           => get_bloginfo('name'),
214 214
         );
215 215
 
216 216
     }
@@ -222,30 +222,30 @@  discard block
 block discarded – undo
222 222
 	 * @param  bool     $force_one_line_item Create only one item for this invoice.
223 223
 	 * @return array
224 224
 	 */
225
-	protected function get_line_item_args( $invoice, $force_one_line_item = false ) {
225
+	protected function get_line_item_args($invoice, $force_one_line_item = false) {
226 226
 
227 227
         // Maybe send invoice as a single item.
228
-		if ( $force_one_line_item ) {
229
-            return $this->get_line_item_args_single_item( $invoice );
228
+		if ($force_one_line_item) {
229
+            return $this->get_line_item_args_single_item($invoice);
230 230
         }
231 231
 
232 232
         // Send each line item individually.
233 233
         $line_item_args = array();
234 234
 
235 235
         // Prepare line items.
236
-        $this->prepare_line_items( $invoice );
236
+        $this->prepare_line_items($invoice);
237 237
 
238 238
         // Add taxes to the cart
239
-        if ( wpinv_use_taxes() && $invoice->is_taxable() ) {
240
-            $line_item_args['tax_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_tax(), 2 );
239
+        if (wpinv_use_taxes() && $invoice->is_taxable()) {
240
+            $line_item_args['tax_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_tax(), 2);
241 241
         }
242 242
 
243 243
         // Add discount.
244
-        if ( $invoice->get_total_discount() > 0 ) {
245
-            $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 );
244
+        if ($invoice->get_total_discount() > 0) {
245
+            $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_discount(), 2);
246 246
         }
247 247
 
248
-		return array_merge( $line_item_args, $this->get_line_items() );
248
+		return array_merge($line_item_args, $this->get_line_items());
249 249
 
250 250
     }
251 251
 
@@ -255,11 +255,11 @@  discard block
 block discarded – undo
255 255
 	 * @param  WPInv_Invoice $invoice Invoice object.
256 256
 	 * @return array
257 257
 	 */
258
-	protected function get_line_item_args_single_item( $invoice ) {
258
+	protected function get_line_item_args_single_item($invoice) {
259 259
 		$this->delete_line_items();
260 260
 
261
-        $item_name = wp_sprintf( __( 'Invoice %s', 'invoicing' ), $invoice->get_number() );
262
-		$this->add_line_item( $item_name, 1, wpinv_round_amount( (float) $invoice->get_total(), 2, true ), $invoice->get_id() );
261
+        $item_name = wp_sprintf(__('Invoice %s', 'invoicing'), $invoice->get_number());
262
+		$this->add_line_item($item_name, 1, wpinv_round_amount((float) $invoice->get_total(), 2, true), $invoice->get_id());
263 263
 
264 264
 		return $this->get_line_items();
265 265
     }
@@ -283,19 +283,19 @@  discard block
 block discarded – undo
283 283
 	 *
284 284
 	 * @param  WPInv_Invoice $invoice Invoice object.
285 285
 	 */
286
-	protected function prepare_line_items( $invoice ) {
286
+	protected function prepare_line_items($invoice) {
287 287
 		$this->delete_line_items();
288 288
 
289 289
 		// Items.
290
-		foreach ( $invoice->get_items() as $item ) {
290
+		foreach ($invoice->get_items() as $item) {
291 291
 			$amount   = $item->get_price();
292 292
 			$quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity();
293
-			$this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() );
293
+			$this->add_line_item($item->get_raw_name(), $quantity, $amount, $item->get_id());
294 294
         }
295 295
 
296 296
         // Fees.
297
-		foreach ( $invoice->get_fees() as $fee => $data ) {
298
-            $this->add_line_item( $fee, 1, wpinv_sanitize_amount( $data['initial_fee'] ) );
297
+		foreach ($invoice->get_fees() as $fee => $data) {
298
+            $this->add_line_item($fee, 1, wpinv_sanitize_amount($data['initial_fee']));
299 299
         }
300 300
 
301 301
     }
@@ -308,20 +308,20 @@  discard block
 block discarded – undo
308 308
 	 * @param  float  $amount Amount.
309 309
 	 * @param  string $item_number Item number.
310 310
 	 */
311
-	protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) {
312
-		$index = ( count( $this->line_items ) / 4 ) + 1;
311
+	protected function add_line_item($item_name, $quantity = 1, $amount = 0.0, $item_number = '') {
312
+		$index = (count($this->line_items) / 4) + 1;
313 313
 
314 314
 		/**
315 315
 		 * Prevent error "Things don't appear to be working at the moment. (https://www.sandbox.paypal.com/webapps/hermes/error)"
316 316
 		 */
317
-		$item_name = str_replace( "#", "", $item_name );
317
+		$item_name = str_replace("#", "", $item_name);
318 318
 
319 319
 		$item = apply_filters(
320 320
 			'getpaid_paypal_line_item',
321 321
 			array(
322
-				'item_name'   => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
322
+				'item_name'   => html_entity_decode(getpaid_limit_length($item_name ? wp_strip_all_tags($item_name) : __('Item', 'invoicing'), 127), ENT_NOQUOTES, 'UTF-8'),
323 323
 				'quantity'    => (float) $quantity,
324
-				'amount'      => wpinv_sanitize_amount( (float) $amount, 2 ),
324
+				'amount'      => wpinv_sanitize_amount((float) $amount, 2),
325 325
 				'item_number' => $item_number,
326 326
 			),
327 327
 			$item_name,
@@ -330,12 +330,12 @@  discard block
 block discarded – undo
330 330
 			$item_number
331 331
 		);
332 332
 
333
-		$this->line_items[ 'item_name_' . $index ]   = getpaid_limit_length( $item['item_name'], 127 );
334
-        $this->line_items[ 'quantity_' . $index ]    = $item['quantity'];
333
+		$this->line_items['item_name_' . $index] = getpaid_limit_length($item['item_name'], 127);
334
+        $this->line_items['quantity_' . $index] = $item['quantity'];
335 335
 
336 336
         // The price or amount of the product, service, or contribution, not including shipping, handling, or tax.
337
-		$this->line_items[ 'amount_' . $index ]      = $item['amount'] * $item['quantity'];
338
-		$this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 );
337
+		$this->line_items['amount_' . $index]      = $item['amount'] * $item['quantity'];
338
+		$this->line_items['item_number_' . $index] = getpaid_limit_length($item['item_number'], 127);
339 339
     }
340 340
 
341 341
     /**
@@ -347,19 +347,19 @@  discard block
 block discarded – undo
347 347
 	 * @param array    $paypal_args Arguments sent to Paypal in the request.
348 348
 	 * @return array
349 349
 	 */
350
-	protected function fix_request_length( $invoice, $paypal_args ) {
350
+	protected function fix_request_length($invoice, $paypal_args) {
351 351
 		$max_paypal_length = 2083;
352
-		$query_candidate   = http_build_query( $paypal_args, '', '&' );
352
+		$query_candidate   = http_build_query($paypal_args, '', '&');
353 353
 
354
-		if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) {
354
+		if (strlen($this->endpoint . $query_candidate) <= $max_paypal_length) {
355 355
 			return $paypal_args;
356 356
 		}
357 357
 
358 358
 		return apply_filters(
359 359
 			'getpaid_paypal_args',
360 360
 			array_merge(
361
-				$this->get_transaction_args( $invoice ),
362
-				$this->get_line_item_args( $invoice, true )
361
+				$this->get_transaction_args($invoice),
362
+				$this->get_line_item_args($invoice, true)
363 363
 			),
364 364
 			$invoice
365 365
 		);
@@ -372,10 +372,10 @@  discard block
 block discarded – undo
372 372
 	 * @param  array $paypal_args PayPal args.
373 373
 	 * @param  WPInv_Invoice    $invoice Invoice object.
374 374
 	 */
375
-	public function process_subscription( $paypal_args, $invoice ) {
375
+	public function process_subscription($paypal_args, $invoice) {
376 376
 
377 377
         // Make sure this is a subscription.
378
-        if ( ! $invoice->is_recurring() || ! $subscription = getpaid_get_invoice_subscription( $invoice ) ) {
378
+        if (!$invoice->is_recurring() || !$subscription = getpaid_get_invoice_subscription($invoice)) {
379 379
             return $paypal_args;
380 380
         }
381 381
 
@@ -383,23 +383,23 @@  discard block
 block discarded – undo
383 383
         $paypal_args['cmd'] = '_xclick-subscriptions';
384 384
 
385 385
         // Subscription name.
386
-        $paypal_args['item_name'] = wp_sprintf( __( 'Invoice %s', 'invoicing' ), $invoice->get_number() );
386
+        $paypal_args['item_name'] = wp_sprintf(__('Invoice %s', 'invoicing'), $invoice->get_number());
387 387
 
388 388
         // Get subscription args.
389
-        $period                 = strtoupper( substr( $subscription->get_period(), 0, 1 ) );
389
+        $period                 = strtoupper(substr($subscription->get_period(), 0, 1));
390 390
         $interval               = (int) $subscription->get_frequency();
391 391
         $bill_times             = (int) $subscription->get_bill_times();
392
-        $initial_amount         = (float) wpinv_sanitize_amount( $invoice->get_initial_total(), 2 );
393
-        $recurring_amount       = (float) wpinv_sanitize_amount( $invoice->get_recurring_total(), 2 );
394
-        $subscription_item      = $invoice->get_recurring( true );
392
+        $initial_amount         = (float) wpinv_sanitize_amount($invoice->get_initial_total(), 2);
393
+        $recurring_amount       = (float) wpinv_sanitize_amount($invoice->get_recurring_total(), 2);
394
+        $subscription_item      = $invoice->get_recurring(true);
395 395
 
396 396
 		// Convert 365 days to 1 year.
397
-		if ( 'D' == $period && 365 == $interval ) {
397
+		if ('D' == $period && 365 == $interval) {
398 398
 			$period = 'Y';
399 399
 			$interval = 1;
400 400
 		}
401 401
 
402
-        if ( $subscription_item->has_free_trial() ) {
402
+        if ($subscription_item->has_free_trial()) {
403 403
 
404 404
             $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount;
405 405
 
@@ -409,28 +409,28 @@  discard block
 block discarded – undo
409 409
 			// Trial period.
410 410
 			$paypal_args['t1'] = $subscription_item->get_trial_period();
411 411
 
412
-        } elseif ( $initial_amount != $recurring_amount ) {
412
+        } elseif ($initial_amount != $recurring_amount) {
413 413
 
414 414
             // No trial period, but initial amount includes a sign-up fee and/or other items, so charge it as a separate period.
415 415
 
416
-            if ( 1 == $bill_times ) {
416
+            if (1 == $bill_times) {
417 417
                 $param_number = 3;
418 418
             } else {
419 419
                 $param_number = 1;
420 420
             }
421 421
 
422
-            $paypal_args[ 'a' . $param_number ] = $initial_amount ? $initial_amount : 0;
422
+            $paypal_args['a' . $param_number] = $initial_amount ? $initial_amount : 0;
423 423
 
424 424
             // Sign Up interval
425
-            $paypal_args[ 'p' . $param_number ] = $interval;
425
+            $paypal_args['p' . $param_number] = $interval;
426 426
 
427 427
             // Sign Up unit of duration
428
-            $paypal_args[ 't' . $param_number ] = $period;
428
+            $paypal_args['t' . $param_number] = $period;
429 429
 
430 430
         }
431 431
 
432 432
         // We have a recurring payment
433
-		if ( ! isset( $param_number ) || 1 == $param_number ) {
433
+		if (!isset($param_number) || 1 == $param_number) {
434 434
 
435 435
 			// Subscription price
436 436
 			$paypal_args['a3'] = $recurring_amount;
@@ -444,7 +444,7 @@  discard block
 block discarded – undo
444 444
         }
445 445
 
446 446
         // Recurring payments
447
-		if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) {
447
+		if (1 == $bill_times || ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial() && 2 == $bill_times)) {
448 448
 
449 449
 			// Non-recurring payments
450 450
 			$paypal_args['src'] = 0;
@@ -453,15 +453,15 @@  discard block
 block discarded – undo
453 453
 
454 454
 			$paypal_args['src'] = 1;
455 455
 
456
-			if ( $bill_times > 0 ) {
456
+			if ($bill_times > 0) {
457 457
 
458 458
 				// An initial period is being used to charge a sign-up fee
459
-				if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) {
459
+				if ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial()) {
460 460
 					$bill_times--;
461 461
 				}
462 462
 
463 463
                 // Make sure it's not over the max of 52
464
-                $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 );
464
+                $paypal_args['srt'] = ($bill_times <= 52 ? absint($bill_times) : 52);
465 465
 
466 466
 			}
467 467
         }
@@ -470,10 +470,10 @@  discard block
 block discarded – undo
470 470
         $paypal_args['rm'] = 2;
471 471
 
472 472
         // Get rid of redudant items.
473
-        foreach ( array( 'item_name_1', 'quantity_1', 'amount_1', 'item_number_1' ) as $arg ) {
473
+        foreach (array('item_name_1', 'quantity_1', 'amount_1', 'item_number_1') as $arg) {
474 474
 
475
-            if ( isset( $paypal_args[ $arg ] ) ) {
476
-                unset( $paypal_args[ $arg ] );
475
+            if (isset($paypal_args[$arg])) {
476
+                unset($paypal_args[$arg]);
477 477
             }
478 478
 		}
479 479
 
@@ -491,20 +491,20 @@  discard block
 block discarded – undo
491 491
 	 * @since 2.8.24
492 492
 	 * @param WPInv_Invoice $invoice Invoice object.
493 493
 	 */
494
-	public function refund_invoice( $invoice ) {
494
+	public function refund_invoice($invoice) {
495 495
 
496
-		if ( $invoice->get_gateway() !== $this->id ) {
496
+		if ($invoice->get_gateway() !== $this->id) {
497 497
 			return;
498 498
 		}
499 499
 
500
-		$mode	= $this->is_sandbox( $invoice ) ? 'sandbox' : 'live';
501
-		$result = GetPaid_PayPal_API::refund_capture( $invoice->get_transaction_id(), array(), $mode );
500
+		$mode = $this->is_sandbox($invoice) ? 'sandbox' : 'live';
501
+		$result = GetPaid_PayPal_API::refund_capture($invoice->get_transaction_id(), array(), $mode);
502 502
 
503
-		if ( is_wp_error( $result ) ) {
503
+		if (is_wp_error($result)) {
504 504
 			$invoice->add_system_note(
505 505
 				sprintf(
506 506
 					// translators: %s is the error message.
507
-					__( 'An error occured while trying to refund invoice #%1$s in PayPal: %2$s', 'invoicing' ),
507
+					__('An error occured while trying to refund invoice #%1$s in PayPal: %2$s', 'invoicing'),
508 508
 					$invoice->get_id(),
509 509
 					$result->get_error_message()
510 510
 				)
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
 			$invoice->add_system_note(
514 514
 				sprintf(
515 515
 					// translators: %s is the refund ID.
516
-					__( 'Successfully refunded invoice #%1$s in PayPal. Refund ID: %2$s', 'invoicing' ),
516
+					__('Successfully refunded invoice #%1$s in PayPal. Refund ID: %2$s', 'invoicing'),
517 517
 					$invoice->get_id(),
518 518
 					$result->id
519 519
 				)
@@ -527,50 +527,50 @@  discard block
 block discarded – undo
527 527
 	 * @since 2.8.24
528 528
 	 * @param WPInv_Subscription $subscription Subscription object.
529 529
 	 */
530
-	public function subscription_cancelled( $subscription ) {
530
+	public function subscription_cancelled($subscription) {
531 531
 
532
-		if ( $subscription->get_gateway() != $this->id ) {
532
+		if ($subscription->get_gateway() != $this->id) {
533 533
 			return;
534 534
 		}
535 535
 
536 536
 		$invoice = $subscription->get_parent_invoice();
537 537
 
538 538
 		// Abort if the parent invoice does not exist.
539
-		if ( ! $invoice->exists() ) {
539
+		if (!$invoice->exists()) {
540 540
 			return;
541 541
 		}
542 542
 
543
-		$mode	= $this->is_sandbox( $invoice ) ? 'sandbox' : 'live';
543
+		$mode = $this->is_sandbox($invoice) ? 'sandbox' : 'live';
544 544
 		$result = GetPaid_PayPal_API::cancel_subscription( 
545 545
 			$invoice->get_remote_subscription_id(), 
546 546
 			array(
547
-				'reason' => __(' Customer requested cancellation', 'invoicing' ),
547
+				'reason' => __(' Customer requested cancellation', 'invoicing'),
548 548
 			), 
549 549
 			$mode 
550 550
 		);
551 551
 
552
-		if ( is_wp_error( $result ) ) {
552
+		if (is_wp_error($result)) {
553 553
 
554 554
 			$error = sprintf(
555 555
 				// translators: %s is the subscription ID.
556
-				__( 'An error occured while trying to cancel subscription #%s in PayPal.', 'invoicing' ),
556
+				__('An error occured while trying to cancel subscription #%s in PayPal.', 'invoicing'),
557 557
 				$subscription->get_id()
558 558
 			);
559 559
 
560
-			getpaid_admin()->show_error( $error . ' ' . $result->get_error_message() );
560
+			getpaid_admin()->show_error($error . ' ' . $result->get_error_message());
561 561
 
562
-			if ( ! is_admin() ) {
563
-				wpinv_set_error( $result->get_error_code(), $error );
562
+			if (!is_admin()) {
563
+				wpinv_set_error($result->get_error_code(), $error);
564 564
 			}
565 565
 
566 566
 			return;
567 567
 		}
568 568
 
569
-		if ( is_admin() ) {
569
+		if (is_admin()) {
570 570
 			getpaid_admin()->show_success(
571 571
 				sprintf(
572 572
 					// translators: %s is the subscription ID.
573
-					__( 'Successfully cancelled subscription #%s in PayPal.', 'invoicing' ),
573
+					__('Successfully cancelled subscription #%s in PayPal.', 'invoicing'),
574 574
 					$subscription->get_id()
575 575
 				)
576 576
 			);
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
 	 * @return void
585 585
 	 */
586 586
 	public function verify_ipn() {
587
-        new GetPaid_Paypal_Gateway_IPN_Handler( $this );
587
+        new GetPaid_Paypal_Gateway_IPN_Handler($this);
588 588
     }
589 589
 
590 590
     /**
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
     public function sandbox_notice() {
594 594
 
595 595
         return sprintf(
596
-			__( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %1$sPayPal Sandbox Testing Guide%2$s for more details.', 'invoicing' ),
596
+			__('SANDBOX ENABLED. You can use sandbox testing accounts only. See the %1$sPayPal Sandbox Testing Guide%2$s for more details.', 'invoicing'),
597 597
 			'<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">',
598 598
 			'</a>'
599 599
 		);
@@ -605,41 +605,41 @@  discard block
 block discarded – undo
605 605
 	 *
606 606
 	 * @param array $admin_settings
607 607
 	 */
608
-	public function admin_settings( $admin_settings ) {
608
+	public function admin_settings($admin_settings) {
609 609
 
610 610
         $currencies = sprintf(
611
-            __( 'Supported Currencies: %s', 'invoicing' ),
612
-            implode( ', ', $this->currencies )
611
+            __('Supported Currencies: %s', 'invoicing'),
612
+            implode(', ', $this->currencies)
613 613
         );
614 614
 
615 615
         $admin_settings['paypal_active']['desc'] .= " ($currencies)";
616
-        $admin_settings['paypal_desc']['std']     = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' );
616
+        $admin_settings['paypal_desc']['std']     = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing');
617 617
 
618 618
 		// Access tokens.
619
-		$live_email      = wpinv_get_option( 'paypal_email' );
620
-		$sandbox_email   = wpinv_get_option( 'paypal_sandbox_email' );
619
+		$live_email      = wpinv_get_option('paypal_email');
620
+		$sandbox_email   = wpinv_get_option('paypal_sandbox_email');
621 621
 
622 622
 		$admin_settings['paypal_connect'] = array(
623 623
 			'type' => 'hook',
624 624
 			'id'   => 'paypal_connect',
625
-			'name' => __( 'Connect to PayPal', 'invoicing' ),
625
+			'name' => __('Connect to PayPal', 'invoicing'),
626 626
 		);
627 627
 
628 628
         $admin_settings['paypal_email'] = array(
629 629
             'type'  => 'text',
630 630
 			'class' => 'live-auth-data',
631 631
             'id'    => 'paypal_email',
632
-            'name'  => __( 'Live Email Address', 'invoicing' ),
633
-            'desc'  => __( 'The email address of your PayPal account.', 'invoicing' ),
632
+            'name'  => __('Live Email Address', 'invoicing'),
633
+            'desc'  => __('The email address of your PayPal account.', 'invoicing'),
634 634
         );
635 635
 
636 636
 		$admin_settings['paypal_sandbox_email'] = array(
637 637
             'type'  => 'text',
638 638
 			'class' => 'sandbox-auth-data',
639 639
             'id'    => 'paypal_sandbox_email',
640
-            'name'  => __( 'Sandbox Email Address', 'invoicing' ),
641
-            'desc'  => __( 'The email address of your sandbox PayPal account.', 'invoicing' ),
642
-			'std'   => wpinv_get_option( 'paypal_email', '' ),
640
+            'name'  => __('Sandbox Email Address', 'invoicing'),
641
+            'desc'  => __('The email address of your sandbox PayPal account.', 'invoicing'),
642
+			'std'   => wpinv_get_option('paypal_email', ''),
643 643
         );
644 644
 
645 645
 		// Client ID and secret.
@@ -647,41 +647,41 @@  discard block
 block discarded – undo
647 647
 			'type'  => 'text',
648 648
 			'class' => 'live-auth-data',
649 649
 			'id'    => 'paypal_client_id',
650
-			'name'  => __( 'Live Client ID', 'invoicing' ),
651
-			'desc'  => __( 'The client ID of your PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing' ),
650
+			'name'  => __('Live Client ID', 'invoicing'),
651
+			'desc'  => __('The client ID of your PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing'),
652 652
 		);
653 653
 
654 654
 		$admin_settings['paypal_sandbox_client_id'] = array(
655 655
 			'type'  => 'text',
656 656
 			'class' => 'sandbox-auth-data',
657 657
 			'id'    => 'paypal_sandbox_client_id',
658
-			'name'  => __( 'Sandbox Client ID', 'invoicing' ),
659
-			'desc'  => __( 'The client ID of your sandbox PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing' ),
660
-			'std'   => wpinv_get_option( 'paypal_client_id', '' ),
658
+			'name'  => __('Sandbox Client ID', 'invoicing'),
659
+			'desc'  => __('The client ID of your sandbox PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing'),
660
+			'std'   => wpinv_get_option('paypal_client_id', ''),
661 661
 		);
662 662
 
663 663
 		$admin_settings['paypal_secret'] = array(
664 664
 			'type'  => 'text',
665 665
 			'class' => 'live-auth-data',
666 666
 			'id'    => 'paypal_secret',
667
-			'name'  => __( 'Live Secret', 'invoicing' ),
668
-			'desc'  => __( 'The secret of your PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing' ),
667
+			'name'  => __('Live Secret', 'invoicing'),
668
+			'desc'  => __('The secret of your PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing'),
669 669
 		);
670 670
 
671 671
 		$admin_settings['paypal_sandbox_secret'] = array(
672 672
 			'type'  => 'text',
673 673
 			'class' => 'sandbox-auth-data',
674 674
 			'id'    => 'paypal_sandbox_secret',
675
-			'name'  => __( 'Sandbox Secret', 'invoicing' ),
676
-			'desc'  => __( 'The secret of your sandbox PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing' ),
675
+			'name'  => __('Sandbox Secret', 'invoicing'),
676
+			'desc'  => __('The secret of your sandbox PayPal account. You can retrieve this from your PayPal developer account.', 'invoicing'),
677 677
 		);
678 678
 
679 679
         $admin_settings['paypal_ipn_url'] = array(
680 680
             'type'     => 'ipn_url',
681 681
             'id'       => 'paypal_ipn_url',
682
-            'name'     => __( 'IPN Url', 'invoicing' ),
682
+            'name'     => __('IPN Url', 'invoicing'),
683 683
             'std'      => $this->notify_url,
684
-            'desc'     => __( "If you've not enabled IPNs in your paypal account, use the above URL to enable them.", 'invoicing' ) . ' <a href="https://developer.paypal.com/docs/api-basics/notifications/ipn/"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>',
684
+            'desc'     => __("If you've not enabled IPNs in your paypal account, use the above URL to enable them.", 'invoicing') . ' <a href="https://developer.paypal.com/docs/api-basics/notifications/ipn/"><em>' . __('Learn more.', 'invoicing') . '</em></a>',
685 685
             'readonly' => true,
686 686
         );
687 687
 
@@ -694,9 +694,9 @@  discard block
 block discarded – undo
694 694
 	 * @param string $url
695 695
 	 * @param WPInv_Subscription $subscription
696 696
 	 */
697
-	public function filter_cancel_subscription_url( $url, $subscription ) {
697
+	public function filter_cancel_subscription_url($url, $subscription) {
698 698
 
699
-		if ( $this->id !== $subscription->get_gateway() ) {
699
+		if ($this->id !== $subscription->get_gateway()) {
700 700
 			return $url;
701 701
 		}
702 702
 
@@ -704,16 +704,16 @@  discard block
 block discarded – undo
704 704
 		$profile_id = $subscription->get_profile_id();
705 705
 
706 706
 		// Bail if no profile ID.
707
-		if ( empty( $profile_id ) ) {
707
+		if (empty($profile_id)) {
708 708
 			return $url;
709 709
 		}
710 710
 
711 711
 		$cancel_url = 'https://www.paypal.com/myaccount/autopay/connect/%s/cancel';
712
-		if ( $this->is_sandbox( $subscription->get_parent_payment() ) ) {
712
+		if ($this->is_sandbox($subscription->get_parent_payment())) {
713 713
 			$cancel_url = 'https://www.sandbox.paypal.com/myaccount/autopay/connect/%s/cancel';
714 714
 		}
715 715
 
716
-		return sprintf( $cancel_url, $profile_id );
716
+		return sprintf($cancel_url, $profile_id);
717 717
 	}
718 718
 
719 719
 	/**
@@ -723,8 +723,8 @@  discard block
 block discarded – undo
723 723
      * @param array $data
724 724
      * @return string
725 725
 	 */
726
-	public static function maybe_get_connect_url( $url = '', $data = array() ) {
727
-		return self::get_connect_url( false, urldecode( $data['redirect'] ) );
726
+	public static function maybe_get_connect_url($url = '', $data = array()) {
727
+		return self::get_connect_url(false, urldecode($data['redirect']));
728 728
 	}
729 729
 
730 730
 	/**
@@ -735,25 +735,25 @@  discard block
 block discarded – undo
735 735
 	 * @param string $redirect
736 736
      * @return string
737 737
 	 */
738
-	public static function get_connect_url( $is_sandbox, $redirect = '' ) {
738
+	public static function get_connect_url($is_sandbox, $redirect = '') {
739 739
 
740 740
         $redirect_url = add_query_arg(
741 741
             array(
742 742
                 'getpaid-admin-action' => 'connect_paypal',
743 743
                 'page'                 => 'wpinv-settings',
744
-                'live_mode'            => (int) empty( $is_sandbox ),
744
+                'live_mode'            => (int) empty($is_sandbox),
745 745
                 'tab'                  => 'gateways',
746 746
                 'section'              => 'paypal',
747
-                'getpaid-nonce'        => wp_create_nonce( 'getpaid-nonce' ),
748
-				'redirect'             => urlencode( $redirect ),
747
+                'getpaid-nonce'        => wp_create_nonce('getpaid-nonce'),
748
+				'redirect'             => urlencode($redirect),
749 749
             ),
750
-            admin_url( 'admin.php' )
750
+            admin_url('admin.php')
751 751
         );
752 752
 
753 753
         return add_query_arg(
754 754
             array(
755
-                'live_mode'    => (int) empty( $is_sandbox ),
756
-                'redirect_url' => urlencode( str_replace( '&amp;', '&', $redirect_url ) ),
755
+                'live_mode'    => (int) empty($is_sandbox),
756
+                'redirect_url' => urlencode(str_replace('&amp;', '&', $redirect_url)),
757 757
             ),
758 758
             'https://ayecode.io/oauth/paypal'
759 759
         );
@@ -769,10 +769,10 @@  discard block
 block discarded – undo
769 769
 
770 770
         ?>
771 771
 			<div class="wpinv-paypal-connect-live">
772
-				<a class="button button-primary" href="<?php echo esc_url( self::get_connect_url( false ) ); ?>"><?php esc_html_e( 'Connect to PayPal', 'invoicing' ); ?></a>
772
+				<a class="button button-primary" href="<?php echo esc_url(self::get_connect_url(false)); ?>"><?php esc_html_e('Connect to PayPal', 'invoicing'); ?></a>
773 773
 			</div>
774 774
 			<div class="wpinv-paypal-connect-sandbox">
775
-				<a class="button button-primary" href="<?php echo esc_url( self::get_connect_url( true ) ); ?>"><?php esc_html_e( 'Connect to PayPal Sandbox', 'invoicing' ); ?></a>
775
+				<a class="button button-primary" href="<?php echo esc_url(self::get_connect_url(true)); ?>"><?php esc_html_e('Connect to PayPal Sandbox', 'invoicing'); ?></a>
776 776
 			</div>
777 777
 
778 778
             <script>
@@ -813,26 +813,26 @@  discard block
 block discarded – undo
813 813
 	 * @param array $data Connection data.
814 814
 	 * @return void
815 815
 	 */
816
-	public function connect_paypal( $data ) {
816
+	public function connect_paypal($data) {
817 817
 
818 818
 		$sandbox      = $this->is_sandbox();
819
-		$data         = wp_unslash( $data );
820
-		$access_token = empty( $data['access_token'] ) ? '' : sanitize_text_field( $data['access_token'] );
819
+		$data         = wp_unslash($data);
820
+		$access_token = empty($data['access_token']) ? '' : sanitize_text_field($data['access_token']);
821 821
 
822
-		if ( isset( $data['live_mode'] ) ) {
823
-			$sandbox = empty( $data['live_mode'] );
822
+		if (isset($data['live_mode'])) {
823
+			$sandbox = empty($data['live_mode']);
824 824
 		}
825 825
 
826
-		wpinv_update_option( 'paypal_sandbox', (int) $sandbox );
827
-		wpinv_update_option( 'paypal_active', 1 );
826
+		wpinv_update_option('paypal_sandbox', (int) $sandbox);
827
+		wpinv_update_option('paypal_active', 1);
828 828
 
829
-		if ( ! empty( $data['error_description'] ) ) {
830
-			getpaid_admin()->show_error( wp_kses_post( urldecode( $data['error_description'] ) ) );
829
+		if (!empty($data['error_description'])) {
830
+			getpaid_admin()->show_error(wp_kses_post(urldecode($data['error_description'])));
831 831
 		} else {
832 832
 
833 833
 			// Retrieve the user info.
834 834
 			$user_info = wp_remote_get(
835
-				! $sandbox ? 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' : 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1',
835
+				!$sandbox ? 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' : 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1',
836 836
 				array(
837 837
 
838 838
 					'headers' => array(
@@ -843,33 +843,33 @@  discard block
 block discarded – undo
843 843
 				)
844 844
 			);
845 845
 
846
-			if ( is_wp_error( $user_info ) ) {
847
-				getpaid_admin()->show_error( wp_kses_post( $user_info->get_error_message() ) );
846
+			if (is_wp_error($user_info)) {
847
+				getpaid_admin()->show_error(wp_kses_post($user_info->get_error_message()));
848 848
 			} else {
849 849
 
850 850
 				// Create application.
851
-				$user_info = json_decode( wp_remote_retrieve_body( $user_info ) );
851
+				$user_info = json_decode(wp_remote_retrieve_body($user_info));
852 852
 
853
-				if ( $sandbox ) {
854
-					wpinv_update_option( 'paypal_sandbox_email', sanitize_email( $user_info->emails[0]->value ) );
855
-					wpinv_update_option( 'paypal_sandbox_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
856
-					set_transient( 'getpaid_paypal_sandbox_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
857
-					getpaid_admin()->show_success( __( 'Successfully connected your PayPal sandbox account', 'invoicing' ) );
853
+				if ($sandbox) {
854
+					wpinv_update_option('paypal_sandbox_email', sanitize_email($user_info->emails[0]->value));
855
+					wpinv_update_option('paypal_sandbox_refresh_token', sanitize_text_field(urldecode($data['refresh_token'])));
856
+					set_transient('getpaid_paypal_sandbox_access_token', sanitize_text_field(urldecode($data['access_token'])), (int) $data['expires_in']);
857
+					getpaid_admin()->show_success(__('Successfully connected your PayPal sandbox account', 'invoicing'));
858 858
 				} else {
859
-					wpinv_update_option( 'paypal_email', sanitize_email( $user_info->emails[0]->value ) );
860
-					wpinv_update_option( 'paypal_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
861
-					set_transient( 'getpaid_paypal_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
862
-					getpaid_admin()->show_success( __( 'Successfully connected your PayPal account', 'invoicing' ) );
859
+					wpinv_update_option('paypal_email', sanitize_email($user_info->emails[0]->value));
860
+					wpinv_update_option('paypal_refresh_token', sanitize_text_field(urldecode($data['refresh_token'])));
861
+					set_transient('getpaid_paypal_access_token', sanitize_text_field(urldecode($data['access_token'])), (int) $data['expires_in']);
862
+					getpaid_admin()->show_success(__('Successfully connected your PayPal account', 'invoicing'));
863 863
 				}
864 864
 			}
865 865
 		}
866 866
 
867
-		$redirect = empty( $data['redirect'] ) ? admin_url( 'admin.php?page=wpinv-settings&tab=gateways&section=paypal' ) : urldecode( $data['redirect'] );
867
+		$redirect = empty($data['redirect']) ? admin_url('admin.php?page=wpinv-settings&tab=gateways&section=paypal') : urldecode($data['redirect']);
868 868
 
869
-		if ( isset( $data['step'] ) ) {
870
-			$redirect = add_query_arg( 'step', $data['step'], $redirect );
869
+		if (isset($data['step'])) {
870
+			$redirect = add_query_arg('step', $data['step'], $redirect);
871 871
 		}
872
-		wp_redirect( $redirect );
872
+		wp_redirect($redirect);
873 873
 		exit;
874 874
 	}
875 875
 
Please login to merge, or discard this patch.
templates/payment-forms/elements/checkbox.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -7,24 +7,24 @@
 block discarded – undo
7 7
  * @version 2.8.24
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-$label = empty( $label ) ? '' : wp_kses_post( $label );
13
-$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) );
12
+$label = empty($label) ? '' : wp_kses_post($label);
13
+$label_class = sanitize_key(preg_replace('/[^A-Za-z0-9_-]/', '-', $label));
14 14
 
15
-if ( ! empty( $required ) ) {
15
+if (!empty($required)) {
16 16
 	$label .= "<span class='text-danger'> *</span>";
17 17
 }
18 18
 
19 19
 aui()->input(
20 20
 	array(
21 21
 		'type'      => 'checkbox',
22
-		'name'      => esc_attr( $id ),
23
-		'id'        => esc_attr( $element_id ),
24
-		'required'  => ! empty( $required ),
22
+		'name'      => esc_attr($id),
23
+		'id'        => esc_attr($element_id),
24
+		'required'  => !empty($required),
25 25
 		'label'     => $label,
26
-		'value'     => esc_attr__( 'Yes', 'invoicing' ),
27
-		'help_text' => empty( $description ) ? '' : wp_kses_post( $description ),
26
+		'value'     => esc_attr__('Yes', 'invoicing'),
27
+		'help_text' => empty($description) ? '' : wp_kses_post($description),
28 28
 		'class'     => $label_class
29 29
 	),
30 30
 	true
Please login to merge, or discard this patch.
templates/payment-forms/elements/address.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -7,60 +7,60 @@  discard block
 block discarded – undo
7 7
  * @version 2.8.24
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-if ( empty( $fields ) ) {
12
+if (empty($fields)) {
13 13
 	return;
14 14
 }
15 15
 
16 16
 // A prefix for all ids (so that a form can be included in the same page multiple times).
17
-$uniqid = uniqid( '_' );
17
+$uniqid = uniqid('_');
18 18
 
19 19
 // Prepare the user's country.
20
-if ( ! empty( $form->invoice ) ) {
20
+if (!empty($form->invoice)) {
21 21
 	$country = $form->invoice->get_country();
22 22
 }
23 23
 
24
-if ( empty( $country ) ) {
25
-	$country = empty( $country ) ? getpaid_get_ip_country() : $country;
26
-	$country = empty( $country ) ? wpinv_get_default_country() : $country;
24
+if (empty($country)) {
25
+	$country = empty($country) ? getpaid_get_ip_country() : $country;
26
+	$country = empty($country) ? wpinv_get_default_country() : $country;
27 27
 }
28 28
 
29 29
 // A prefix for all ids (so that a form can be included in the same page multiple times).
30
-$uniqid = uniqid( '_' );
30
+$uniqid = uniqid('_');
31 31
 
32
-$address_type = empty( $address_type ) ? 'billing' : $address_type;
32
+$address_type = empty($address_type) ? 'billing' : $address_type;
33 33
 ?>
34 34
 
35
-<?php if ( 'both' === $address_type ) : ?>
35
+<?php if ('both' === $address_type) : ?>
36 36
 	<!-- Start Billing/Shipping Address Title -->
37 37
 	<h4 class="mb-3 getpaid-shipping-billing-address-title">
38
-		<?php esc_html_e( 'Billing / Shipping Address', 'invoicing' ); ?>
38
+		<?php esc_html_e('Billing / Shipping Address', 'invoicing'); ?>
39 39
 	</h4>
40 40
 	<!-- End Billing Address Title -->
41 41
 
42 42
 	<!-- Start Billing Address Title -->
43 43
 	<h4 class="mb-3 getpaid-billing-address-title">
44
-		<?php esc_html_e( 'Billing Address', 'invoicing' ); ?>
44
+		<?php esc_html_e('Billing Address', 'invoicing'); ?>
45 45
 	</h4>
46 46
 	<!-- End Billing Address Title -->
47 47
 <?php endif; ?>
48 48
 
49
-<?php if ( 'both' === $address_type || 'billing' === $address_type ) : ?>
49
+<?php if ('both' === $address_type || 'billing' === $address_type) : ?>
50 50
 	<!-- Start Billing Address -->
51 51
 	<div class="getpaid-billing-address-wrapper">
52 52
 		<?php
53 53
 			$field_type = 'billing';
54 54
 
55
-			wpinv_get_template( 'payment-forms/elements/address-fields.php', array( 'form' => $form, 'fields' => $fields, 'address_type' => $address_type, 'field_type' => $field_type, 'uniqid' => $uniqid, 'country' => $country ) );
55
+			wpinv_get_template('payment-forms/elements/address-fields.php', array('form' => $form, 'fields' => $fields, 'address_type' => $address_type, 'field_type' => $field_type, 'uniqid' => $uniqid, 'country' => $country));
56 56
 
57
-			do_action( 'getpaid_after_payment_form_billing_fields', $form );
57
+			do_action('getpaid_after_payment_form_billing_fields', $form);
58 58
 		?>
59 59
 	</div>
60 60
 	<!-- End Billing Address -->
61 61
 <?php endif; ?>
62 62
 
63
-<?php if ( 'both' === $address_type ) : ?>
63
+<?php if ('both' === $address_type) : ?>
64 64
 	<?php
65 65
 		aui()->input(
66 66
 			array(
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 				'name'     => 'same-shipping-address',
69 69
 				'id'       => "shipping-toggle$uniqid",
70 70
 				'required' => false,
71
-				'label'    => empty( $shipping_address_toggle ) ? esc_html__( 'Same billing & shipping address.', 'invoicing' ) : wp_kses_post( $shipping_address_toggle ),
71
+				'label'    => empty($shipping_address_toggle) ? esc_html__('Same billing & shipping address.', 'invoicing') : wp_kses_post($shipping_address_toggle),
72 72
 				'value'    => 1,
73 73
 				'checked'  => true,
74 74
 				'class'    => 'chkbox-same-shipping-address'
@@ -78,20 +78,20 @@  discard block
 block discarded – undo
78 78
 	?>
79 79
 	<!-- Start Shipping Address Title -->
80 80
 	<h4 class="mb-3 getpaid-shipping-address-title">
81
-		<?php esc_html_e( 'Shipping Address', 'invoicing' ); ?>
81
+		<?php esc_html_e('Shipping Address', 'invoicing'); ?>
82 82
 	</h4>
83 83
 	<!-- End Shipping Address Title -->
84 84
 <?php endif; ?>
85 85
 
86
-<?php if ( 'both' === $address_type || 'shipping' === $address_type ) : ?>
86
+<?php if ('both' === $address_type || 'shipping' === $address_type) : ?>
87 87
 	<!-- Start Shipping Address -->
88 88
 	<div class="getpaid-shipping-address-wrapper">
89 89
 		<?php
90 90
 			$field_type = 'shipping';
91 91
 
92
-			wpinv_get_template( 'payment-forms/elements/address-fields.php', array( 'form' => $form, 'fields' => $fields, 'address_type' => $address_type, 'field_type' => $field_type, 'uniqid' => $uniqid, 'country' => $country ) );
92
+			wpinv_get_template('payment-forms/elements/address-fields.php', array('form' => $form, 'fields' => $fields, 'address_type' => $address_type, 'field_type' => $field_type, 'uniqid' => $uniqid, 'country' => $country));
93 93
 
94
-			do_action( 'getpaid_after_payment_form_shipping_fields', $form );
94
+			do_action('getpaid_after_payment_form_shipping_fields', $form);
95 95
 		?>
96 96
 	</div>
97 97
 	<!-- End Shipping Address -->
Please login to merge, or discard this patch.
includes/class-wpinv.php 1 patch
Spacing   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @since   1.0.0
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Main Invoicing class.
@@ -56,8 +56,8 @@  discard block
 block discarded – undo
56 56
 	 * @param string $prop The prop to set.
57 57
 	 * @param mixed $value The value to retrieve.
58 58
 	 */
59
-	public function set( $prop, $value ) {
60
-		$this->data[ $prop ] = $value;
59
+	public function set($prop, $value) {
60
+		$this->data[$prop] = $value;
61 61
 	}
62 62
 
63 63
 	/**
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 	 * @param string $prop The prop to set.
67 67
 	 * @return mixed The value.
68 68
 	 */
69
-	public function get( $prop ) {
70
-		if ( isset( $this->data[ $prop ] ) ) {
71
-			return $this->data[ $prop ];
69
+	public function get($prop) {
70
+		if (isset($this->data[$prop])) {
71
+			return $this->data[$prop];
72 72
 		}
73 73
 
74 74
 		return null;
@@ -79,31 +79,31 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	public function set_properties() {
81 81
 		// Sessions.
82
-		$this->set( 'session', new WPInv_Session_Handler() );
83
-		$GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility.
82
+		$this->set('session', new WPInv_Session_Handler());
83
+		$GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility.
84 84
 		$GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility.
85 85
 
86 86
 		// Init other objects.
87
-		$this->set( 'notes', new WPInv_Notes() );
88
-		$this->set( 'api', new WPInv_API() );
89
-		$this->set( 'post_types', new GetPaid_Post_Types() );
90
-		$this->set( 'template', new GetPaid_Template() );
91
-		$this->set( 'admin', new GetPaid_Admin() );
92
-		$this->set( 'subscriptions', new WPInv_Subscriptions() );
93
-		$this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() );
94
-		$this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() );
95
-		$this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() );
96
-		$this->set( 'payment_forms', new GetPaid_Payment_Forms() );
97
-		$this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() );
98
-		$this->set( 'data_retention', new WPInv_Data_Retention() );
87
+		$this->set('notes', new WPInv_Notes());
88
+		$this->set('api', new WPInv_API());
89
+		$this->set('post_types', new GetPaid_Post_Types());
90
+		$this->set('template', new GetPaid_Template());
91
+		$this->set('admin', new GetPaid_Admin());
92
+		$this->set('subscriptions', new WPInv_Subscriptions());
93
+		$this->set('invoice_emails', new GetPaid_Invoice_Notification_Emails());
94
+		$this->set('subscription_emails', new GetPaid_Subscription_Notification_Emails());
95
+		$this->set('daily_maintenace', new GetPaid_Daily_Maintenance());
96
+		$this->set('payment_forms', new GetPaid_Payment_Forms());
97
+		$this->set('maxmind', new GetPaid_MaxMind_Geolocation());
98
+		$this->set('data_retention', new WPInv_Data_Retention());
99 99
 	}
100 100
 
101 101
 	 /**
102 102
 	 * Define plugin constants.
103 103
 	 */
104 104
 	public function define_constants() {
105
-		define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
106
-		define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
105
+		define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
106
+		define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
107 107
 		$this->version = WPINV_VERSION;
108 108
 	}
109 109
 
@@ -114,38 +114,38 @@  discard block
 block discarded – undo
114 114
 	 */
115 115
 	protected function init_hooks() {
116 116
 		/* Internationalize the text strings used. */
117
-		add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
117
+		add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
118 118
 
119 119
 		// Init the plugin after WordPress inits.
120
-		add_action( 'init', array( $this, 'init' ), 1 );
121
-		add_action( 'init', array( $this, 'maybe_process_ipn' ), 100 );
122
-		add_action( 'init', array( $this, 'wpinv_actions' ) );
123
-		add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 );
124
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 );
125
-		add_action( 'wp_footer', array( $this, 'wp_footer' ) );
126
-		add_action( 'wp_head', array( $this, 'wp_head' ) );
127
-		add_action( 'widgets_init', array( $this, 'register_widgets' ) );
128
-		add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
129
-		add_filter( 'the_seo_framework_sitemap_supported_post_types', array( $this, 'exclude_invoicing_post_types' ) );
130
-		add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
131
-
132
-		add_filter( 'query_vars', array( $this, 'custom_query_vars' ) );
133
-		add_action( 'init', array( $this, 'add_rewrite_rule' ), 10, 0 );
134
-		add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 );
120
+		add_action('init', array($this, 'init'), 1);
121
+		add_action('init', array($this, 'maybe_process_ipn'), 100);
122
+		add_action('init', array($this, 'wpinv_actions'));
123
+		add_action('init', array($this, 'maybe_do_authenticated_action'), 100);
124
+		add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 11);
125
+		add_action('wp_footer', array($this, 'wp_footer'));
126
+		add_action('wp_head', array($this, 'wp_head'));
127
+		add_action('widgets_init', array($this, 'register_widgets'));
128
+		add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids'));
129
+		add_filter('the_seo_framework_sitemap_supported_post_types', array($this, 'exclude_invoicing_post_types'));
130
+		add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
131
+
132
+		add_filter('query_vars', array($this, 'custom_query_vars'));
133
+		add_action('init', array($this, 'add_rewrite_rule'), 10, 0);
134
+		add_action('pre_get_posts', array($this, 'maybe_process_new_ipn'), 1);
135 135
 
136 136
 		// Fires after registering actions.
137
-		do_action( 'wpinv_actions', $this );
138
-		do_action( 'getpaid_actions', $this );
137
+		do_action('wpinv_actions', $this);
138
+		do_action('getpaid_actions', $this);
139 139
 	}
140 140
 
141 141
 	public function plugins_loaded() {
142 142
 		/* Internationalize the text strings used. */
143 143
 		$this->load_textdomain();
144 144
 
145
-		do_action( 'wpinv_loaded' );
145
+		do_action('wpinv_loaded');
146 146
 
147 147
 		// Fix oxygen page builder conflict
148
-		if ( function_exists( 'ct_css_output' ) ) {
148
+		if (function_exists('ct_css_output')) {
149 149
 			wpinv_oxygen_fix_conflict();
150 150
 		}
151 151
 	}
@@ -163,9 +163,9 @@  discard block
 block discarded – undo
163 163
 	 */
164 164
 	public function load_textdomain() {
165 165
 		// Determines the current locale.
166
-		if ( function_exists( 'determine_locale' ) ) {
166
+		if (function_exists('determine_locale')) {
167 167
 			$locale = determine_locale();
168
-		} else if ( function_exists( 'get_user_locale' ) ) {
168
+		} else if (function_exists('get_user_locale')) {
169 169
 			$locale = get_user_locale();
170 170
 		} else {
171 171
 			$locale = get_locale();
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
 		/**
175 175
 		 * Filter the locale to use for translations.
176 176
 		 */
177
-		$locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
177
+		$locale = apply_filters('plugin_locale', $locale, 'invoicing');
178 178
 
179
-		unload_textdomain( 'invoicing', true );
180
-		load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
181
-		load_plugin_textdomain( 'invoicing', false, plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/' );
179
+		unload_textdomain('invoicing', true);
180
+		load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
181
+		load_plugin_textdomain('invoicing', false, plugin_basename(dirname(WPINV_PLUGIN_FILE)) . '/languages/');
182 182
 	}
183 183
 
184 184
 	/**
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
 
212 212
 		// Register autoloader.
213 213
 		try {
214
-			spl_autoload_register( array( $this, 'autoload' ), true );
215
-		} catch ( Exception $e ) {
216
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
214
+			spl_autoload_register(array($this, 'autoload'), true);
215
+		} catch (Exception $e) {
216
+			wpinv_error_log($e->getMessage(), '', __FILE__, 149, true);
217 217
 		}
218 218
 
219 219
 		require_once WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php';
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 		require_once WPINV_PLUGIN_DIR . 'widgets/invoice.php';
240 240
 		require_once WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php';
241 241
 
242
-		if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
242
+		if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
243 243
 			GetPaid_Post_Types_Admin::init();
244 244
 
245 245
 			require_once WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php';
@@ -250,15 +250,15 @@  discard block
 block discarded – undo
250 250
 			require_once WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php';
251 251
 			// load the user class only on the users.php page
252 252
 			global $pagenow;
253
-			if ( $pagenow == 'users.php' ) {
253
+			if ($pagenow == 'users.php') {
254 254
 				new WPInv_Admin_Users();
255 255
 			}
256 256
 		}
257 257
 
258 258
 		// Register cli commands
259
-		if ( defined( 'WP_CLI' ) && WP_CLI ) {
259
+		if (defined('WP_CLI') && WP_CLI) {
260 260
 			require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php';
261
-			WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
261
+			WP_CLI::add_command('invoicing', 'WPInv_CLI');
262 262
 		}
263 263
 	}
264 264
 
@@ -270,20 +270,20 @@  discard block
 block discarded – undo
270 270
 	 * @since       1.0.19
271 271
 	 * @return      void
272 272
 	 */
273
-	public function autoload( $class_name ) {
273
+	public function autoload($class_name) {
274 274
 		// Normalize the class name...
275
-		$class_name  = strtolower( $class_name );
275
+		$class_name = strtolower($class_name);
276 276
 
277 277
 		// ... and make sure it is our class.
278
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
278
+		if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) {
279 279
 			return;
280 280
 		}
281 281
 
282 282
 		// Next, prepare the file name from the class.
283
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
283
+		$file_name = 'class-' . str_replace('_', '-', $class_name) . '.php';
284 284
 
285 285
 		// Base path of the classes.
286
-		$plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
286
+		$plugin_path = untrailingslashit(WPINV_PLUGIN_DIR);
287 287
 
288 288
 		// And an array of possible locations in order of importance.
289 289
 		$locations = array(
@@ -298,9 +298,9 @@  discard block
 block discarded – undo
298 298
 			"$plugin_path/includes/admin/meta-boxes",
299 299
 		);
300 300
 
301
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
302
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
303
-				include trailingslashit( $location ) . $file_name;
301
+		foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) {
302
+			if (file_exists(trailingslashit($location) . $file_name)) {
303
+				include trailingslashit($location) . $file_name;
304 304
 				break;
305 305
 			}
306 306
 		}
@@ -311,7 +311,7 @@  discard block
 block discarded – undo
311 311
 	 */
312 312
 	public function init() {
313 313
 		// Fires before getpaid inits.
314
-		do_action( 'before_getpaid_init', $this );
314
+		do_action('before_getpaid_init', $this);
315 315
 
316 316
 		// Maybe upgrade.
317 317
 		$this->maybe_upgrade_database();
@@ -328,17 +328,17 @@  discard block
 block discarded – undo
328 328
 			)
329 329
 		);
330 330
 
331
-		foreach ( $gateways as $id => $class ) {
332
-			$this->gateways[ $id ] = new $class();
331
+		foreach ($gateways as $id => $class) {
332
+			$this->gateways[$id] = new $class();
333 333
 		}
334 334
 
335
-		if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) {
335
+		if ('yes' != get_option('wpinv_renamed_gateways')) {
336 336
 			GetPaid_Installer::rename_gateways_label();
337
-			update_option( 'wpinv_renamed_gateways', 'yes' );
337
+			update_option('wpinv_renamed_gateways', 'yes');
338 338
 		}
339 339
 
340 340
 		// Fires after getpaid inits.
341
-		do_action( 'getpaid_init', $this );
341
+		do_action('getpaid_init', $this);
342 342
 	}
343 343
 
344 344
 	/**
@@ -346,51 +346,51 @@  discard block
 block discarded – undo
346 346
 	 */
347 347
 	public function maybe_process_ipn() {
348 348
 		// Ensure that this is an IPN request.
349
-		if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) {
349
+		if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) {
350 350
 			return;
351 351
 		}
352 352
 
353
-		$gateway = sanitize_text_field( $_GET['wpi-gateway'] );
353
+		$gateway = sanitize_text_field($_GET['wpi-gateway']);
354 354
 
355
-		do_action( 'wpinv_verify_payment_ipn', $gateway );
356
-		do_action( "wpinv_verify_{$gateway}_ipn" );
355
+		do_action('wpinv_verify_payment_ipn', $gateway);
356
+		do_action("wpinv_verify_{$gateway}_ipn");
357 357
 		exit;
358 358
 	}
359 359
 
360 360
 	public function enqueue_scripts() {
361 361
 		// Fires before adding scripts.
362
-		do_action( 'getpaid_enqueue_scripts' );
362
+		do_action('getpaid_enqueue_scripts');
363 363
 
364 364
 		$localize                         = array();
365
-		$localize['ajax_url']             = admin_url( 'admin-ajax.php' );
365
+		$localize['ajax_url']             = admin_url('admin-ajax.php');
366 366
 		$localize['thousands']            = wpinv_thousands_separator();
367 367
 		$localize['decimals']             = wpinv_decimal_separator();
368
-		$localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
369
-		$localize['txtComplete']          = __( 'Continue', 'invoicing' );
368
+		$localize['nonce']                = wp_create_nonce('wpinv-nonce');
369
+		$localize['txtComplete']          = __('Continue', 'invoicing');
370 370
 		$localize['UseTaxes']             = wpinv_use_taxes();
371
-		$localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
372
-		$localize['loading']              = __( 'Loading...', 'invoicing' );
373
-		$localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
371
+		$localize['formNonce']            = wp_create_nonce('getpaid_form_nonce');
372
+		$localize['loading']              = __('Loading...', 'invoicing');
373
+		$localize['connectionError']      = __('Could not establish a connection to the server.', 'invoicing');
374 374
 		$localize['recaptchaSettings']    = getpaid_get_recaptcha_settings();
375 375
 
376
-		$localize = apply_filters( 'wpinv_front_js_localize', $localize );
376
+		$localize = apply_filters('wpinv_front_js_localize', $localize);
377 377
 
378 378
 		// reCaptcha.
379
-		if ( getpaid_is_recaptcha_enabled() && ( $recaptcha_js = getpaid_recaptcha_api_url() ) ) {
380
-			wp_enqueue_script( 'recaptcha', $recaptcha_js, array(), null, true ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
379
+		if (getpaid_is_recaptcha_enabled() && ($recaptcha_js = getpaid_recaptcha_api_url())) {
380
+			wp_enqueue_script('recaptcha', $recaptcha_js, array(), null, true); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
381 381
 		}
382 382
 
383
-		wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.min.js', array( 'jquery' ), WPINV_VERSION, true );
384
-		wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
383
+		wp_enqueue_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.min.js', array('jquery'), WPINV_VERSION, true);
384
+		wp_localize_script('wpinv-front-script', 'WPInv', $localize);
385 385
 	}
386 386
 
387 387
 	public function wpinv_actions() {
388
-		if ( isset( $_REQUEST['wpi_action'] ) ) {
389
-			do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
388
+		if (isset($_REQUEST['wpi_action'])) {
389
+			do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
390 390
 		}
391 391
 
392
-		if ( defined( 'WP_ALL_IMPORT_ROOT_DIR' ) ) {
393
-			include plugin_dir_path( __FILE__ ) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php';
392
+		if (defined('WP_ALL_IMPORT_ROOT_DIR')) {
393
+			include plugin_dir_path(__FILE__) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php';
394 394
 		}
395 395
 	}
396 396
 
@@ -401,21 +401,21 @@  discard block
 block discarded – undo
401 401
 	 * current user owns the invoice/subscription.
402 402
 	 */
403 403
 	public function maybe_do_authenticated_action() {
404
-		if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
405
-			$key  = sanitize_key( $_REQUEST['getpaid-action'] );
406
-			$data = wp_unslash( $_REQUEST );
404
+		if (isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
405
+			$key  = sanitize_key($_REQUEST['getpaid-action']);
406
+			$data = wp_unslash($_REQUEST);
407 407
 
408
-			if ( is_user_logged_in() ) {
409
-				do_action( "getpaid_authenticated_action_$key", $data );
408
+			if (is_user_logged_in()) {
409
+				do_action("getpaid_authenticated_action_$key", $data);
410 410
 			}
411 411
 
412
-			do_action( "getpaid_unauthenticated_action_$key", $data );
412
+			do_action("getpaid_unauthenticated_action_$key", $data);
413 413
 		}
414 414
 	}
415 415
 
416
-	public function pre_get_posts( $wp_query ) {
417
-		if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
418
-			$wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) );
416
+	public function pre_get_posts($wp_query) {
417
+		if (!is_admin() && !empty($wp_query->query_vars['post_type']) && getpaid_is_invoice_post_type($wp_query->query_vars['post_type']) && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
418
+			$wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses(false, false, $wp_query->query_vars['post_type']));
419 419
 		}
420 420
 
421 421
 		return $wp_query;
@@ -430,17 +430,17 @@  discard block
 block discarded – undo
430 430
 
431 431
 		// Currently, UX Builder does not work particulaly well with SuperDuper.
432 432
 		// So we disable our widgets when editing a page with UX Builder.
433
-		if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) {
433
+		if (function_exists('ux_builder_is_active') && ux_builder_is_active()) {
434 434
 			return;
435 435
 		}
436 436
 
437
-		$block_widget_init_screens = function_exists( 'sd_pagenow_exclude' ) ? sd_pagenow_exclude() : array();
437
+		$block_widget_init_screens = function_exists('sd_pagenow_exclude') ? sd_pagenow_exclude() : array();
438 438
 
439
-		if ( is_admin() && $pagenow && in_array( $pagenow, $block_widget_init_screens ) ) {
439
+		if (is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) {
440 440
 			// don't initiate in these conditions.
441 441
 		} else {
442 442
 			// Only load allowed widgets.
443
-			$exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array();
443
+			$exclude = function_exists('sd_widget_exclude') ? sd_widget_exclude() : array();
444 444
 			$widgets = apply_filters(
445 445
 				'getpaid_widget_classes',
446 446
 				array(
@@ -456,15 +456,15 @@  discard block
 block discarded – undo
456 456
 			);
457 457
 
458 458
 			// For each widget...
459
-			foreach ( $widgets as $widget ) {
459
+			foreach ($widgets as $widget) {
460 460
 				// Abort early if it is excluded for this page.
461
-				if ( in_array( $widget, $exclude ) ) {
461
+				if (in_array($widget, $exclude)) {
462 462
 					continue;
463 463
 				}
464 464
 
465 465
 				// SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it.
466
-				if ( is_subclass_of( $widget, 'WP_Widget' ) ) {
467
-					register_widget( $widget );
466
+				if (is_subclass_of($widget, 'WP_Widget')) {
467
+					register_widget($widget);
468 468
 				} else {
469 469
 					new $widget();
470 470
 				}
@@ -481,28 +481,28 @@  discard block
 block discarded – undo
481 481
 		// Ensure the database tables are up to date.
482 482
 		GetPaid_Installer::maybe_create_db_tables();
483 483
 
484
-		$wpi_version = get_option( 'wpinv_version', 0 );
484
+		$wpi_version = get_option('wpinv_version', 0);
485 485
 
486
-		if ( $wpi_version == WPINV_VERSION ) {
486
+		if ($wpi_version == WPINV_VERSION) {
487 487
 			return;
488 488
 		}
489 489
 
490 490
 		$installer = new GetPaid_Installer();
491 491
 
492
-		if ( empty( $wpi_version ) ) {
493
-			return $installer->upgrade_db( 0 );
492
+		if (empty($wpi_version)) {
493
+			return $installer->upgrade_db(0);
494 494
 		}
495 495
 
496
-		$upgrades  = array(
496
+		$upgrades = array(
497 497
 			'0.0.5' => '004',
498 498
 			'1.0.3' => '102',
499 499
 			'2.0.0' => '118',
500 500
 			'2.8.0' => '279',
501 501
 		);
502 502
 
503
-		foreach ( $upgrades as $key => $method ) {
504
-			if ( version_compare( $wpi_version, $key, '<' ) ) {
505
-				return $installer->upgrade_db( $method );
503
+		foreach ($upgrades as $key => $method) {
504
+			if (version_compare($wpi_version, $key, '<')) {
505
+				return $installer->upgrade_db($method);
506 506
 			}
507 507
 		}
508 508
 	}
@@ -513,11 +513,11 @@  discard block
 block discarded – undo
513 513
 	 * @since 2.0.8
514 514
 	 */
515 515
 	public function maybe_flush_permalinks() {
516
-		$flush = get_option( 'wpinv_flush_permalinks', 0 );
516
+		$flush = get_option('wpinv_flush_permalinks', 0);
517 517
 
518
-		if ( ! empty( $flush ) ) {
518
+		if (!empty($flush)) {
519 519
 			flush_rewrite_rules();
520
-			delete_option( 'wpinv_flush_permalinks' );
520
+			delete_option('wpinv_flush_permalinks');
521 521
 		}
522 522
 	}
523 523
 
@@ -527,9 +527,9 @@  discard block
 block discarded – undo
527 527
 	 * @since 1.0.19
528 528
 	 * @param int[] $excluded_posts_ids
529 529
 	 */
530
-	public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ) {
530
+	public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) {
531 531
 		// Ensure that we have an array.
532
-		if ( ! is_array( $excluded_posts_ids ) ) {
532
+		if (!is_array($excluded_posts_ids)) {
533 533
 			$excluded_posts_ids = array();
534 534
 		}
535 535
 
@@ -537,25 +537,25 @@  discard block
 block discarded – undo
537 537
 		$our_pages = array();
538 538
 
539 539
 		// Checkout page.
540
-		$our_pages[] = wpinv_get_option( 'checkout_page', false );
540
+		$our_pages[] = wpinv_get_option('checkout_page', false);
541 541
 
542 542
 		// Success page.
543
-		$our_pages[] = wpinv_get_option( 'success_page', false );
543
+		$our_pages[] = wpinv_get_option('success_page', false);
544 544
 
545 545
 		// Failure page.
546
-		$our_pages[] = wpinv_get_option( 'failure_page', false );
546
+		$our_pages[] = wpinv_get_option('failure_page', false);
547 547
 
548 548
 		// History page.
549
-		$our_pages[] = wpinv_get_option( 'invoice_history_page', false );
549
+		$our_pages[] = wpinv_get_option('invoice_history_page', false);
550 550
 
551 551
 		// Subscriptions page.
552
-		$our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
552
+		$our_pages[] = wpinv_get_option('invoice_subscription_page', false);
553 553
 
554
-		$our_pages   = array_map( 'intval', array_filter( $our_pages ) );
554
+		$our_pages   = array_map('intval', array_filter($our_pages));
555 555
 
556 556
 		$excluded_posts_ids = $excluded_posts_ids + $our_pages;
557 557
 
558
-		return array_unique( $excluded_posts_ids );
558
+		return array_unique($excluded_posts_ids);
559 559
 	}
560 560
 
561 561
 	/**
@@ -564,14 +564,14 @@  discard block
 block discarded – undo
564 564
 	 * @since 1.0.19
565 565
 	 * @param string[] $post_types
566 566
 	 */
567
-	public function exclude_invoicing_post_types( $post_types ) {
567
+	public function exclude_invoicing_post_types($post_types) {
568 568
 		// Ensure that we have an array.
569
-		if ( ! is_array( $post_types ) ) {
569
+		if (!is_array($post_types)) {
570 570
 			$post_types = array();
571 571
 		}
572 572
 
573 573
 		// Remove our post types.
574
-		return array_diff( $post_types, array_keys( getpaid_get_invoice_post_types() ) );
574
+		return array_diff($post_types, array_keys(getpaid_get_invoice_post_types()));
575 575
 	}
576 576
 
577 577
 	/**
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
 	 * @since 2.0.0
581 581
 	 */
582 582
 	public function wp_footer() {
583
-		wpinv_get_template( 'frontend-footer.php' );
583
+		wpinv_get_template('frontend-footer.php');
584 584
 	}
585 585
 
586 586
 	/**
@@ -589,14 +589,14 @@  discard block
 block discarded – undo
589 589
 	 * @since 2.0.0
590 590
 	 */
591 591
 	public function wp_head() {
592
-		wpinv_get_template( 'frontend-head.php' );
592
+		wpinv_get_template('frontend-head.php');
593 593
 	}
594 594
 
595 595
 	/**
596 596
 	 * Custom query vars.
597 597
 	 *
598 598
 	 */
599
-	public function custom_query_vars( $vars ) {
599
+	public function custom_query_vars($vars) {
600 600
 		$vars[] = 'getpaid-ipn';
601 601
 		return $vars;
602 602
 	}
@@ -607,26 +607,26 @@  discard block
 block discarded – undo
607 607
 	 */
608 608
 	public function add_rewrite_rule() {
609 609
 		$tag = 'getpaid-ipn';
610
-		add_rewrite_tag( "%$tag%", '([^&]+)' );
611
-		add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top' );
610
+		add_rewrite_tag("%$tag%", '([^&]+)');
611
+		add_rewrite_rule("^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top');
612 612
 	}
613 613
 
614 614
 	/**
615 615
 	 * Processes non-query string ipns.
616 616
 	 *
617 617
 	 */
618
-	public function maybe_process_new_ipn( $query ) {
619
-		if ( is_admin() || ! $query->is_main_query() ) {
618
+	public function maybe_process_new_ipn($query) {
619
+		if (is_admin() || !$query->is_main_query()) {
620 620
 			return;
621 621
 		}
622 622
 
623
-		$gateway = get_query_var( 'getpaid-ipn' );
623
+		$gateway = get_query_var('getpaid-ipn');
624 624
 
625
-		if ( ! empty( $gateway ) ) {
626
-			$gateway = sanitize_text_field( $gateway );
625
+		if (!empty($gateway)) {
626
+			$gateway = sanitize_text_field($gateway);
627 627
 			nocache_headers();
628
-			do_action( 'wpinv_verify_payment_ipn', $gateway );
629
-			do_action( "wpinv_verify_{$gateway}_ipn" );
628
+			do_action('wpinv_verify_payment_ipn', $gateway);
629
+			do_action("wpinv_verify_{$gateway}_ipn");
630 630
 			exit;
631 631
 		}
632 632
 	}
Please login to merge, or discard this patch.
includes/admin/class-wpinv-admin-menus.php 1 patch
Spacing   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Setup menus in WP admin.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * WC_Admin_Menus Class.
@@ -13,15 +13,15 @@  discard block
 block discarded – undo
13 13
      * Hook in tabs.
14 14
      */
15 15
     public function __construct() {
16
-        add_action( 'admin_head', array( $this, 'set_admin_menu_class' ) );
17
-        add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 );
18
-        add_action( 'admin_menu', array( $this, 'add_customers_menu' ), 18 );
19
-        add_action( 'admin_menu', array( $this, 'add_subscriptions_menu' ), 40 );
20
-        add_action( 'admin_menu', array( $this, 'add_addons_menu' ), 100 );
21
-        add_action( 'admin_menu', array( $this, 'add_settings_menu' ), 60 );
22
-        add_action( 'admin_menu', array( $this, 'add_anonymization_logs_menu' ), 40 );
23
-        add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 );
24
-        add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) );
16
+        add_action('admin_head', array($this, 'set_admin_menu_class'));
17
+        add_action('admin_menu', array($this, 'admin_menu'), 10);
18
+        add_action('admin_menu', array($this, 'add_customers_menu'), 18);
19
+        add_action('admin_menu', array($this, 'add_subscriptions_menu'), 40);
20
+        add_action('admin_menu', array($this, 'add_addons_menu'), 100);
21
+        add_action('admin_menu', array($this, 'add_settings_menu'), 60);
22
+        add_action('admin_menu', array($this, 'add_anonymization_logs_menu'), 40);
23
+        add_action('admin_menu', array($this, 'remove_admin_submenus'), 10);
24
+        add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes'));
25 25
     }
26 26
 
27 27
     /**
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	public function set_admin_menu_class() {
31 31
 		global $current_screen, $parent_file, $submenu_file;
32 32
 
33
-        if ( ! empty( $current_screen->id ) && in_array( $current_screen->id, array( 'wpi_discount', 'wpi_payment_form', 'wpi_invoice' ) ) ) {
33
+        if (!empty($current_screen->id) && in_array($current_screen->id, array('wpi_discount', 'wpi_payment_form', 'wpi_invoice'))) {
34 34
 			$parent_file = 'wpinv';
35 35
 			$submenu_file = 'edit.php?post_type=' . $current_screen->id;
36 36
         }
@@ -39,14 +39,14 @@  discard block
 block discarded – undo
39 39
 
40 40
     public function admin_menu() {
41 41
 
42
-        $capability = apply_filters( 'invoicing_capability', wpinv_get_capability() );
42
+        $capability = apply_filters('invoicing_capability', wpinv_get_capability());
43 43
         add_menu_page(
44
-            __( 'GetPaid', 'invoicing' ),
45
-            __( 'GetPaid', 'invoicing' ),
44
+            __('GetPaid', 'invoicing'),
45
+            __('GetPaid', 'invoicing'),
46 46
             $capability,
47 47
             'wpinv',
48 48
             null,
49
-            'data:image/svg+xml;base64,' . base64_encode( file_get_contents( WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg' ) ),
49
+            'data:image/svg+xml;base64,' . base64_encode(file_get_contents(WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg')),
50 50
             '54.123460'
51 51
         );
52 52
 
@@ -58,11 +58,11 @@  discard block
 block discarded – undo
58 58
     public function add_customers_menu() {
59 59
         add_submenu_page(
60 60
             'wpinv',
61
-            __( 'Customers', 'invoicing' ),
62
-            __( 'Customers', 'invoicing' ),
61
+            __('Customers', 'invoicing'),
62
+            __('Customers', 'invoicing'),
63 63
             wpinv_get_capability(),
64 64
             'wpinv-customers',
65
-            array( $this, 'customers_page' )
65
+            array($this, 'customers_page')
66 66
         );
67 67
     }
68 68
 
@@ -72,8 +72,8 @@  discard block
 block discarded – undo
72 72
     public function add_subscriptions_menu() {
73 73
         add_submenu_page(
74 74
             'wpinv',
75
-            __( 'Subscriptions', 'invoicing' ),
76
-            __( 'Subscriptions', 'invoicing' ),
75
+            __('Subscriptions', 'invoicing'),
76
+            __('Subscriptions', 'invoicing'),
77 77
             wpinv_get_capability(),
78 78
             'wpinv-subscriptions',
79 79
             'wpinv_subscriptions_page'
@@ -95,13 +95,13 @@  discard block
 block discarded – undo
95 95
                     width: 120px;
96 96
                 }
97 97
             </style>
98
-            <h1><?php echo esc_html( __( 'Customers', 'invoicing' ) ); ?>&nbsp;<a href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'download_customers' ), 'getpaid-nonce', 'getpaid-nonce' ) ); ?>" class="page-title-action"><?php esc_html_e( 'Export', 'invoicing' ); ?></a></h1>
99
-            <form method="get" style="overflow: auto; width: 100%" action=<?php echo esc_url( add_query_arg( array() ) ); ?>>
98
+            <h1><?php echo esc_html(__('Customers', 'invoicing')); ?>&nbsp;<a href="<?php echo esc_url(wp_nonce_url(add_query_arg('getpaid-admin-action', 'download_customers'), 'getpaid-nonce', 'getpaid-nonce')); ?>" class="page-title-action"><?php esc_html_e('Export', 'invoicing'); ?></a></h1>
99
+            <form method="get" style="overflow: auto; width: 100%" action=<?php echo esc_url(add_query_arg(array())); ?>>
100 100
                 <input type="hidden" name="page" value="wpinv-customers" />
101 101
                 <?php
102 102
                     $table = new WPInv_Customers_Table();
103 103
                     $table->prepare_items();
104
-                    $table->search_box( __( 'Search Customers', 'invoicing' ), 'search-customers' );
104
+                    $table->search_box(__('Search Customers', 'invoicing'), 'search-customers');
105 105
                     $table->display();
106 106
                 ?>
107 107
             </form>
@@ -115,11 +115,11 @@  discard block
 block discarded – undo
115 115
     public function add_settings_menu() {
116 116
         add_submenu_page(
117 117
             'wpinv',
118
-            __( 'Invoice Settings', 'invoicing' ),
119
-            __( 'Settings', 'invoicing' ),
120
-            apply_filters( 'invoicing_capability', wpinv_get_capability() ),
118
+            __('Invoice Settings', 'invoicing'),
119
+            __('Settings', 'invoicing'),
120
+            apply_filters('invoicing_capability', wpinv_get_capability()),
121 121
             'wpinv-settings',
122
-            array( $this, 'options_page' )
122
+            array($this, 'options_page')
123 123
         );
124 124
     }
125 125
 
@@ -131,26 +131,26 @@  discard block
 block discarded – undo
131 131
     public function add_anonymization_logs_menu() {
132 132
         $anonymization_logs_page = new GetPaid_Anonymization_Logs();
133 133
         add_management_page(
134
-            __( 'Anonymization Logs', 'invoicing' ),
135
-            __( 'Anonymization Logs', 'invoicing' ),
134
+            __('Anonymization Logs', 'invoicing'),
135
+            __('Anonymization Logs', 'invoicing'),
136 136
             'manage_options',
137 137
             'wpinv-anonymization-logs',
138
-            array( $anonymization_logs_page, 'display_logs' )
138
+            array($anonymization_logs_page, 'display_logs')
139 139
         );
140 140
     }
141 141
 
142 142
     public function add_addons_menu() {
143
-        if ( ! apply_filters( 'wpi_show_addons_page', true ) ) {
143
+        if (!apply_filters('wpi_show_addons_page', true)) {
144 144
             return;
145 145
         }
146 146
 
147 147
         add_submenu_page(
148 148
             'wpinv',
149
-            __( 'Invoicing extensions', 'invoicing' ),
150
-            __( 'Extensions', 'invoicing' ),
149
+            __('Invoicing extensions', 'invoicing'),
150
+            __('Extensions', 'invoicing'),
151 151
             'manage_options',
152 152
             'wpi-addons',
153
-            array( $this, 'addons_page' )
153
+            array($this, 'addons_page')
154 154
         );
155 155
     }
156 156
 
@@ -161,29 +161,29 @@  discard block
 block discarded – undo
161 161
 
162 162
     function options_page() {
163 163
 
164
-        if ( ! wpinv_current_user_can_manage_invoicing() ) {
164
+        if (!wpinv_current_user_can_manage_invoicing()) {
165 165
             return;
166 166
         }
167 167
 
168 168
         $settings_tabs = wpinv_get_settings_tabs();
169
-        $settings_tabs = empty( $settings_tabs ) ? array() : $settings_tabs;
170
-        $active_tab    = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general';
171
-        $sections      = wpinv_get_settings_tab_sections( $active_tab );
169
+        $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs;
170
+        $active_tab    = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general';
171
+        $sections      = wpinv_get_settings_tab_sections($active_tab);
172 172
         $key           = 'main';
173 173
 
174
-        if ( is_array( $sections ) ) {
175
-            $key = key( $sections );
174
+        if (is_array($sections)) {
175
+            $key = key($sections);
176 176
         }
177 177
 
178 178
         add_thickbox();
179 179
 
180
-        $registered_sections = wpinv_get_settings_tab_sections( $active_tab );
181
-        $section             = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? sanitize_text_field( $_GET['section'] ) : $key;
180
+        $registered_sections = wpinv_get_settings_tab_sections($active_tab);
181
+        $section             = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? sanitize_text_field($_GET['section']) : $key;
182 182
         ?>
183 183
         <div class="wrap">
184 184
             <h1 class="nav-tab-wrapper">
185 185
                 <?php
186
-                foreach ( wpinv_get_settings_tabs() as $tab_id => $tab_name ) {
186
+                foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) {
187 187
                     $tab_url = add_query_arg(
188 188
                         array(
189 189
 							'settings-updated' => false,
@@ -193,23 +193,23 @@  discard block
 block discarded – undo
193 193
                     );
194 194
 
195 195
                     // Remove the section from the tabs so we always end up at the main section
196
-                    $tab_url = remove_query_arg( 'section', $tab_url );
197
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
196
+                    $tab_url = remove_query_arg('section', $tab_url);
197
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
198 198
 
199 199
                     $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
200 200
 
201
-                    echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab ' . esc_attr( $active ) . '">';
202
-                    echo esc_html( $tab_name );
201
+                    echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab ' . esc_attr($active) . '">';
202
+                    echo esc_html($tab_name);
203 203
                     echo '</a>';
204 204
                 }
205 205
                 ?>
206 206
             </h1>
207 207
             <?php
208
-            $number_of_sections = count( $sections );
208
+            $number_of_sections = count($sections);
209 209
             $number = 0;
210
-            if ( $number_of_sections > 1 ) {
210
+            if ($number_of_sections > 1) {
211 211
                 echo '<div><ul class="subsubsub">';
212
-                foreach ( $sections as $section_id => $section_name ) {
212
+                foreach ($sections as $section_id => $section_name) {
213 213
                     echo '<li>';
214 214
                     $number++;
215 215
                     $tab_url = add_query_arg(
@@ -218,16 +218,16 @@  discard block
 block discarded – undo
218 218
 							'tab'              => $active_tab,
219 219
 							'section'          => $section_id,
220 220
                         ),
221
-                        admin_url( 'admin.php?page=wpinv-settings' )
221
+                        admin_url('admin.php?page=wpinv-settings')
222 222
                     );
223
-                    $tab_url = remove_query_arg( 'wpi_sub', $tab_url );
223
+                    $tab_url = remove_query_arg('wpi_sub', $tab_url);
224 224
                     $class = '';
225
-                    if ( $section == $section_id ) {
225
+                    if ($section == $section_id) {
226 226
                         $class = 'current';
227 227
                     }
228
-                    echo '<a class="' . esc_attr( $class ) . '" href="' . esc_url( $tab_url ) . '">' . esc_html( $section_name ) . '</a>';
228
+                    echo '<a class="' . esc_attr($class) . '" href="' . esc_url($tab_url) . '">' . esc_html($section_name) . '</a>';
229 229
 
230
-                    if ( $number != $number_of_sections ) {
230
+                    if ($number != $number_of_sections) {
231 231
                         echo ' | ';
232 232
                     }
233 233
                     echo '</li>';
@@ -239,20 +239,20 @@  discard block
 block discarded – undo
239 239
                 <form method="post" action="options.php">
240 240
                     <table class="form-tablex">
241 241
                         <?php
242
-                        settings_fields( 'wpinv_settings' );
242
+                        settings_fields('wpinv_settings');
243 243
 
244
-                        if ( 'main' === $section ) {
245
-                            do_action( 'wpinv_settings_tab_top', $active_tab );
244
+                        if ('main' === $section) {
245
+                            do_action('wpinv_settings_tab_top', $active_tab);
246 246
                         }
247 247
 
248
-                        do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section );
249
-                        do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section );
250
-                        do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section );
251
-                        do_action( 'getpaid_settings_tab_bottom', $active_tab, $section );
248
+                        do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section);
249
+                        do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section);
250
+                        do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section);
251
+                        do_action('getpaid_settings_tab_bottom', $active_tab, $section);
252 252
 
253 253
                         // For backwards compatibility
254
-                        if ( 'main' === $section ) {
255
-                            do_action( 'wpinv_settings_tab_bottom', $active_tab );
254
+                        if ('main' === $section) {
255
+                            do_action('wpinv_settings_tab_bottom', $active_tab);
256 256
                         }
257 257
                         ?>
258 258
                     </table>
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
     }
265 265
 
266 266
     public function remove_admin_submenus() {
267
-        remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' );
267
+        remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice');
268 268
     }
269 269
 
270 270
     /**
@@ -274,8 +274,8 @@  discard block
 block discarded – undo
274 274
 
275 275
         add_meta_box(
276 276
             'wpinv_endpoints_nav_link',
277
-            __( 'GetPaid endpoints', 'invoicing' ),
278
-            array( $this, 'nav_menu_links' ),
277
+            __('GetPaid endpoints', 'invoicing'),
278
+            array($this, 'nav_menu_links'),
279 279
             'nav-menus',
280 280
             'side',
281 281
             'low'
@@ -290,12 +290,12 @@  discard block
 block discarded – undo
290 290
         $endpoints = $this->get_menu_items();
291 291
         ?>
292 292
         <div id="invoicing-endpoints" class="posttypediv">
293
-            <?php if ( ! empty( $endpoints['pages'] ) ) : ?>
293
+            <?php if (!empty($endpoints['pages'])) : ?>
294 294
                 <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active">
295 295
                     <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear">
296 296
                         <?php
297
-                            $walker = new Walker_Nav_Menu_Checklist( array() );
298
-                            echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $endpoints['pages'] ), 0, (object) array( 'walker' => $walker ) );
297
+                            $walker = new Walker_Nav_Menu_Checklist(array());
298
+                            echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object) array('walker' => $walker));
299 299
                         ?>
300 300
                     </ul>
301 301
                 </div>
@@ -304,11 +304,11 @@  discard block
 block discarded – undo
304 304
             <p class="button-controls wp-clearfix" data-items-type="invoicing-endpoints">
305 305
                 <span class="list-controls hide-if-no-js">
306 306
                     <input type="checkbox" id="invoicing-endpoints-tab" class="select-all">
307
-                    <label for="invoicing-endpoints-tab"><?php esc_html_e( 'Select all', 'invoicing' ); ?></label>
307
+                    <label for="invoicing-endpoints-tab"><?php esc_html_e('Select all', 'invoicing'); ?></label>
308 308
                 </span>
309 309
 
310 310
                 <span class="add-to-menu">
311
-                    <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'invoicing' ); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints">
311
+                    <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'invoicing'); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints">
312 312
                     <span class="spinner"></span>
313 313
                 </span>
314 314
             </p>
@@ -326,18 +326,18 @@  discard block
 block discarded – undo
326 326
 
327 327
         $pages = array(
328 328
             array(
329
-                'id'    => wpinv_get_option( 'invoice_history_page' ),
330
-                'label' => __( 'My Invoices', 'invoicing' ),
329
+                'id'    => wpinv_get_option('invoice_history_page'),
330
+                'label' => __('My Invoices', 'invoicing'),
331 331
             ),
332 332
             array(
333
-                'id'    => wpinv_get_option( 'invoice_subscription_page' ),
334
-                'label' => __( 'My Subscriptions', 'invoicing' ),
333
+                'id'    => wpinv_get_option('invoice_subscription_page'),
334
+                'label' => __('My Subscriptions', 'invoicing'),
335 335
             ),
336 336
         );
337 337
 
338
-        foreach ( apply_filters( 'getpaid_menu_pages', $pages ) as $page ) {
338
+        foreach (apply_filters('getpaid_menu_pages', $pages) as $page) {
339 339
 
340
-            if ( (int) $page['id'] > 0 ) {
340
+            if ((int) $page['id'] > 0) {
341 341
 
342 342
                 $item                   = new stdClass();
343 343
                 $item->object_id        = (int) $page['id'];
@@ -345,11 +345,11 @@  discard block
 block discarded – undo
345 345
                 $item->object           = 'page';
346 346
                 $item->menu_item_parent = 0;
347 347
                 $item->type             = 'post_type';
348
-                $item->title            = esc_html( $page['label'] );
349
-                $item->url              = get_permalink( (int) $page['id'] );
348
+                $item->title            = esc_html($page['label']);
349
+                $item->url              = get_permalink((int) $page['id']);
350 350
                 $item->target           = '';
351 351
                 $item->attr_title       = '';
352
-                $item->classes          = array( 'wpinv-menu-item' );
352
+                $item->classes          = array('wpinv-menu-item');
353 353
                 $item->xfn              = '';
354 354
 
355 355
                 $items['pages'][]       = $item;
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
             }
358 358
 }
359 359
 
360
-        return apply_filters( 'wpinv_menu_items', $items );
360
+        return apply_filters('wpinv_menu_items', $items);
361 361
     }
362 362
 
363 363
 }
Please login to merge, or discard this patch.
includes/class-wpinv-data-retention.php 1 patch
Spacing   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @since   2.8.22
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * WPInv_Data_Retention Class.
@@ -35,13 +35,13 @@  discard block
 block discarded – undo
35 35
      * Class constructor.
36 36
      */
37 37
     public function __construct() {
38
-        add_filter( 'wpinv_settings_misc', array( $this, 'add_data_retention_settings' ) );
38
+        add_filter('wpinv_settings_misc', array($this, 'add_data_retention_settings'));
39 39
 
40
-        add_action( 'wpmu_delete_user', array( $this, 'maybe_handle_user_deletion' ), 1 );
41
-        add_action( 'delete_user', array( $this, 'maybe_handle_user_deletion' ), 1 );
42
-        add_filter( 'wp_privacy_personal_data_erasure_request', array( $this, 'handle_erasure_request' ), 10, 2 );
40
+        add_action('wpmu_delete_user', array($this, 'maybe_handle_user_deletion'), 1);
41
+        add_action('delete_user', array($this, 'maybe_handle_user_deletion'), 1);
42
+        add_filter('wp_privacy_personal_data_erasure_request', array($this, 'handle_erasure_request'), 10, 2);
43 43
 
44
-        add_action( 'getpaid_daily_maintenance', array( $this, 'perform_data_retention_cleanup' ) );
44
+        add_action('getpaid_daily_maintenance', array($this, 'perform_data_retention_cleanup'));
45 45
     }
46 46
 
47 47
     /**
@@ -50,43 +50,43 @@  discard block
 block discarded – undo
50 50
      * @param array $misc_settings Existing misc settings.
51 51
      * @return array Updated misc settings.
52 52
      */
53
-    public function add_data_retention_settings( $misc_settings ) {
53
+    public function add_data_retention_settings($misc_settings) {
54 54
         $misc_settings['data_retention'] = array(
55 55
             'id'   => 'data_retention',
56
-            'name' => '<h3>' . __( 'Data Retention', 'invoicing' ) . '</h3>',
56
+            'name' => '<h3>' . __('Data Retention', 'invoicing') . '</h3>',
57 57
             'type' => 'header',
58 58
         );
59 59
 
60 60
         $misc_settings['data_retention_method'] = array(
61 61
             'id'      => 'data_retention_method',
62
-            'name'    => __( 'Data Handling', 'invoicing' ),
63
-            'desc'    => __( 'Choose how to handle user data when deletion is required.', 'invoicing' ),
62
+            'name'    => __('Data Handling', 'invoicing'),
63
+            'desc'    => __('Choose how to handle user data when deletion is required.', 'invoicing'),
64 64
             'type'    => 'select',
65 65
             'options' => array(
66
-                'anonymize' => __( 'Anonymize data', 'invoicing' ),
67
-                'delete'    => __( 'Delete data without anonymization', 'invoicing' ),
66
+                'anonymize' => __('Anonymize data', 'invoicing'),
67
+                'delete'    => __('Delete data without anonymization', 'invoicing'),
68 68
             ),
69 69
             'std'     => 'anonymize',
70
-            'tooltip' => __( 'Anonymization replaces personal data with non-identifiable information. Direct deletion removes all data permanently.', 'invoicing' ),
70
+            'tooltip' => __('Anonymization replaces personal data with non-identifiable information. Direct deletion removes all data permanently.', 'invoicing'),
71 71
         );
72 72
 
73 73
         $misc_settings['data_retention_period'] = array(
74 74
             'id'      => 'data_retention_period',
75
-            'name'    => __( 'Retention Period', 'invoicing' ),
76
-            'desc'    => __( 'Specify how long to retain customer data after processing.', 'invoicing' ),
75
+            'name'    => __('Retention Period', 'invoicing'),
76
+            'desc'    => __('Specify how long to retain customer data after processing.', 'invoicing'),
77 77
             'type'    => 'select',
78 78
             'options' => array(
79
-                'never' => __( 'Never delete (retain indefinitely)', 'invoicing' ),
80
-                '30'    => __( '30 days', 'invoicing' ),
81
-                '90'    => __( '90 days', 'invoicing' ),
82
-                '180'   => __( '6 months', 'invoicing' ),
83
-                '365'   => __( '1 year', 'invoicing' ),
84
-                '730'   => __( '2 years', 'invoicing' ),
85
-                '1825'  => __( '5 years', 'invoicing' ),
86
-                '3650'  => __( '10 years', 'invoicing' ),
79
+                'never' => __('Never delete (retain indefinitely)', 'invoicing'),
80
+                '30'    => __('30 days', 'invoicing'),
81
+                '90'    => __('90 days', 'invoicing'),
82
+                '180'   => __('6 months', 'invoicing'),
83
+                '365'   => __('1 year', 'invoicing'),
84
+                '730'   => __('2 years', 'invoicing'),
85
+                '1825'  => __('5 years', 'invoicing'),
86
+                '3650'  => __('10 years', 'invoicing'),
87 87
             ),
88 88
             'std'     => '3650',
89
-            'tooltip' => __( 'Choose how long to keep processed customer data before final action. This helps balance data minimization with business needs.', 'invoicing' ),
89
+            'tooltip' => __('Choose how long to keep processed customer data before final action. This helps balance data minimization with business needs.', 'invoicing'),
90 90
         );
91 91
 
92 92
         return $misc_settings;
@@ -97,15 +97,15 @@  discard block
 block discarded – undo
97 97
      *
98 98
      * @param int $user_id The ID of the user being deleted.
99 99
      */
100
-    public function maybe_handle_user_deletion( $user_id ) {
101
-        if ( ! $this->handle_user_deletion ) {
100
+    public function maybe_handle_user_deletion($user_id) {
101
+        if (!$this->handle_user_deletion) {
102 102
             return;
103 103
         }
104 104
 
105
-        if ( current_user_can( 'manage_options' ) ) {
106
-            $this->handle_admin_user_deletion( $user_id );
105
+        if (current_user_can('manage_options')) {
106
+            $this->handle_admin_user_deletion($user_id);
107 107
         } else {
108
-            $this->handle_self_account_deletion( $user_id );
108
+            $this->handle_self_account_deletion($user_id);
109 109
         }
110 110
     }
111 111
 
@@ -115,19 +115,19 @@  discard block
 block discarded – undo
115 115
      * @since 2.8.22
116 116
      * @param int $user_id The ID of the user being deleted.
117 117
      */
118
-    public function handle_admin_user_deletion( $user_id ) {
119
-        if ( $this->has_active_subscriptions( $user_id ) ) {
120
-            $this->prevent_user_deletion( $user_id, 'active_subscriptions' );
118
+    public function handle_admin_user_deletion($user_id) {
119
+        if ($this->has_active_subscriptions($user_id)) {
120
+            $this->prevent_user_deletion($user_id, 'active_subscriptions');
121 121
             return;
122 122
         }
123 123
 
124
-        if ( $this->has_paid_invoices( $user_id ) ) {
125
-            $retention_method = wpinv_get_option( 'data_retention_method', 'anonymize' );
126
-            if ( 'anonymize' === $retention_method ) {
127
-                $this->anonymize_user_data( $user_id );
128
-                $this->prevent_user_deletion( $user_id, 'paid_invoices' );
124
+        if ($this->has_paid_invoices($user_id)) {
125
+            $retention_method = wpinv_get_option('data_retention_method', 'anonymize');
126
+            if ('anonymize' === $retention_method) {
127
+                $this->anonymize_user_data($user_id);
128
+                $this->prevent_user_deletion($user_id, 'paid_invoices');
129 129
             } else {
130
-                $this->delete_user_data( $user_id );
130
+                $this->delete_user_data($user_id);
131 131
             }
132 132
         }
133 133
     }
@@ -138,19 +138,19 @@  discard block
 block discarded – undo
138 138
      * @since 2.8.22
139 139
      * @param int $user_id The ID of the user being deleted.
140 140
      */
141
-    public function handle_self_account_deletion( $user_id ) {
142
-        $this->cancel_active_subscriptions( $user_id );
141
+    public function handle_self_account_deletion($user_id) {
142
+        $this->cancel_active_subscriptions($user_id);
143 143
 
144
-        if ( $this->has_paid_invoices( $user_id ) ) {
145
-            $retention_method = wpinv_get_option( 'data_retention_method', 'anonymize' );
144
+        if ($this->has_paid_invoices($user_id)) {
145
+            $retention_method = wpinv_get_option('data_retention_method', 'anonymize');
146 146
 
147
-            if ( 'anonymize' === $retention_method ) {
148
-                $user = get_userdata( $user_id );
147
+            if ('anonymize' === $retention_method) {
148
+                $user = get_userdata($user_id);
149 149
 
150
-                $this->anonymize_user_data( $user_id );
150
+                $this->anonymize_user_data($user_id);
151 151
 
152
-                $message = apply_filters( 'uwp_get_account_deletion_message', '', $user );
153
-                do_action( 'uwp_send_account_deletion_emails', $user, $message );
152
+                $message = apply_filters('uwp_get_account_deletion_message', '', $user);
153
+                do_action('uwp_send_account_deletion_emails', $user, $message);
154 154
 
155 155
                 $this->end_user_session();
156 156
             }
@@ -164,15 +164,15 @@  discard block
 block discarded – undo
164 164
      * @param int $user_id The ID of the user being checked.
165 165
      * @return bool True if user has active subscriptions, false otherwise.
166 166
      */
167
-    private function has_active_subscriptions( $user_id ) {
167
+    private function has_active_subscriptions($user_id) {
168 168
         $subscriptions = getpaid_get_subscriptions(
169 169
             array(
170
-                'customer_in' => array( (int) $user_id ),
170
+                'customer_in' => array((int) $user_id),
171 171
                 'status'      => 'active',
172 172
             )
173 173
         );
174 174
 
175
-        return ! empty( $subscriptions );
175
+        return !empty($subscriptions);
176 176
     }
177 177
 
178 178
     /**
@@ -181,15 +181,15 @@  discard block
 block discarded – undo
181 181
      * @since 2.8.22
182 182
      * @param int $user_id The ID of the user.
183 183
      */
184
-    private function cancel_active_subscriptions( $user_id ) {
184
+    private function cancel_active_subscriptions($user_id) {
185 185
         $subscriptions = getpaid_get_subscriptions(
186 186
             array(
187
-                'customer_in' => array( (int) $user_id ),
187
+                'customer_in' => array((int) $user_id),
188 188
                 'status'      => 'active',
189 189
             )
190 190
         );
191 191
 
192
-        foreach ( $subscriptions as $subscription ) {
192
+        foreach ($subscriptions as $subscription) {
193 193
             $subscription->cancel();
194 194
         }
195 195
     }
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
      * @param int $user_id The ID of the user being checked.
202 202
      * @return bool True if user has paid invoices, false otherwise.
203 203
      */
204
-    private function has_paid_invoices( $user_id ) {
204
+    private function has_paid_invoices($user_id) {
205 205
         $invoices = wpinv_get_invoices(
206 206
             array(
207 207
                 'user'   => (int) $user_id,
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
             )
210 210
         );
211 211
 
212
-        return ! empty( $invoices->total );
212
+        return !empty($invoices->total);
213 213
     }
214 214
 
215 215
     /**
@@ -219,24 +219,24 @@  discard block
 block discarded – undo
219 219
      * @param int    $user_id The ID of the user being deleted.
220 220
      * @param string $reason  The reason for preventing deletion.
221 221
      */
222
-    private function prevent_user_deletion( $user_id, $reason ) {
223
-        $user = get_userdata( $user_id );
222
+    private function prevent_user_deletion($user_id, $reason) {
223
+        $user = get_userdata($user_id);
224 224
 
225
-        if ( 'active_subscriptions' === $reason ) {
225
+        if ('active_subscriptions' === $reason) {
226 226
             $this->error_message = sprintf(
227 227
                 /* translators: %s: user login */
228
-                esc_html__( 'User deletion for %s has been halted. All active subscriptions should be cancelled first.', 'invoicing' ),
228
+                esc_html__('User deletion for %s has been halted. All active subscriptions should be cancelled first.', 'invoicing'),
229 229
                 $user->user_login
230 230
             );
231 231
         } else {
232 232
             $this->error_message = sprintf(
233 233
                 /* translators: %s: user login */
234
-                esc_html__( 'User deletion for %s has been halted due to paid invoices. Data will be anonymized instead.', 'invoicing' ),
234
+                esc_html__('User deletion for %s has been halted due to paid invoices. Data will be anonymized instead.', 'invoicing'),
235 235
                 $user->user_login
236 236
             );
237 237
         }
238 238
 
239
-        wp_die( $this->error_message, esc_html__( 'User Deletion Halted', 'invoicing' ), array( 'response' => 403 ) );
239
+        wp_die($this->error_message, esc_html__('User Deletion Halted', 'invoicing'), array('response' => 403));
240 240
     }
241 241
 
242 242
     /**
@@ -246,17 +246,17 @@  discard block
 block discarded – undo
246 246
      * @param int $user_id The ID of the user to anonymize.
247 247
      * @return bool True on success, false on failure.
248 248
      */
249
-    private function anonymize_user_data( $user_id ) {
249
+    private function anonymize_user_data($user_id) {
250 250
         global $wpdb;
251 251
 
252
-        $user = get_userdata( $user_id );
253
-        if ( ! $user ) {
252
+        $user = get_userdata($user_id);
253
+        if (!$user) {
254 254
             return false;
255 255
         }
256 256
 
257 257
         $table_name    = $wpdb->prefix . 'getpaid_customers';
258
-        $deletion_date = gmdate( 'Y-m-d', strtotime( '+10 years' ) );
259
-        $hashed_email  = $this->hash_email( $user->user_email );
258
+        $deletion_date = gmdate('Y-m-d', strtotime('+10 years'));
259
+        $hashed_email  = $this->hash_email($user->user_email);
260 260
 
261 261
         $updated = $wpdb->update(
262 262
             $table_name,
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
                 'email_cc'      => $hashed_email,
268 268
                 'phone'         => '',
269 269
             ),
270
-            array( 'user_id' => (int) $user->ID )
270
+            array('user_id' => (int) $user->ID)
271 271
         );
272 272
 
273
-        if ( false === $updated ) {
273
+        if (false === $updated) {
274 274
             return false;
275 275
         }
276 276
 
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
          * @since 2.8.22
288 288
          * @param int $user_id The ID of the user being anonymized.
289 289
          */
290
-        do_action( 'wpinv_anonymize_user_meta_data', $user->ID );
290
+        do_action('wpinv_anonymize_user_meta_data', $user->ID);
291 291
 
292 292
         $user_meta_data = array(
293 293
             'nickname',
@@ -312,13 +312,13 @@  discard block
 block discarded – undo
312 312
          * @param array $user_meta_data The meta fields to be anonymized.
313 313
          * @param int   $user_id          The ID of the user being anonymized.
314 314
          */
315
-        $user_meta_data = apply_filters( 'wpinv_user_meta_data_to_anonymize', $user_meta_data, $user->ID );
315
+        $user_meta_data = apply_filters('wpinv_user_meta_data_to_anonymize', $user_meta_data, $user->ID);
316 316
 
317
-        foreach ( $user_meta_data as $meta_key ) {
318
-            delete_user_meta( $user->ID, $meta_key );
317
+        foreach ($user_meta_data as $meta_key) {
318
+            delete_user_meta($user->ID, $meta_key);
319 319
         }
320 320
 
321
-        return $this->ensure_invoice_anonymization( $user->ID, 'anonymize' );
321
+        return $this->ensure_invoice_anonymization($user->ID, 'anonymize');
322 322
     }
323 323
 
324 324
     /**
@@ -327,15 +327,15 @@  discard block
 block discarded – undo
327 327
      * @param int $user_id The ID of the user to delete.
328 328
      * @return bool True on success, false on failure.
329 329
      */
330
-    private function delete_user_data( $user_id ) {
330
+    private function delete_user_data($user_id) {
331 331
         // Delete associated invoices.
332
-        $this->ensure_invoice_anonymization( $user_id, 'delete' );
332
+        $this->ensure_invoice_anonymization($user_id, 'delete');
333 333
 
334 334
         // Delete the user.
335
-        if ( is_multisite() ) {
336
-            wpmu_delete_user( $user_id );
335
+        if (is_multisite()) {
336
+            wpmu_delete_user($user_id);
337 337
         } else {
338
-            wp_delete_user( $user_id );
338
+            wp_delete_user($user_id);
339 339
         }
340 340
 
341 341
         /**
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
          * @since 2.8.22
345 345
          * @param int $user_id The ID of the user being deleted.
346 346
          */
347
-        do_action( 'wpinv_delete_user_data', $user_id );
347
+        do_action('wpinv_delete_user_data', $user_id);
348 348
 
349 349
         return true;
350 350
     }
@@ -357,8 +357,8 @@  discard block
 block discarded – undo
357 357
      * @param string $action  The action to perform (anonymize or delete).
358 358
      * @return bool True on success, false on failure.
359 359
      */
360
-    public function ensure_invoice_anonymization( $user_id, $action = 'anonymize' ) {
361
-        $invoices = wpinv_get_invoices( array( 'user' => $user_id ) );
360
+    public function ensure_invoice_anonymization($user_id, $action = 'anonymize') {
361
+        $invoices = wpinv_get_invoices(array('user' => $user_id));
362 362
 
363 363
         /**
364 364
          * Filters the invoice meta fields to be anonymized.
@@ -367,22 +367,22 @@  discard block
 block discarded – undo
367 367
          * @param array $inv_meta_data The meta fields to be anonymized.
368 368
          * @param int   $user_id         The ID of the user being processed.
369 369
          */
370
-        $inv_meta_data = apply_filters( 'wpinv_invoice_meta_data_to_anonymize', array(), $user_id );
370
+        $inv_meta_data = apply_filters('wpinv_invoice_meta_data_to_anonymize', array(), $user_id);
371 371
 
372
-        foreach ( $invoices->invoices as $invoice ) {
373
-            foreach ( $inv_meta_data as $meta_key ) {
374
-                delete_post_meta( $invoice->get_id(), $meta_key );
372
+        foreach ($invoices->invoices as $invoice) {
373
+            foreach ($inv_meta_data as $meta_key) {
374
+                delete_post_meta($invoice->get_id(), $meta_key);
375 375
             }
376 376
 
377
-            if ( 'anonymize' === $action ) {
378
-                $hashed_inv_email    = $this->hash_email( $invoice->get_email() );
379
-                $hashed_inv_email_cc = $this->hash_email( $invoice->get_email_cc() );
377
+            if ('anonymize' === $action) {
378
+                $hashed_inv_email    = $this->hash_email($invoice->get_email());
379
+                $hashed_inv_email_cc = $this->hash_email($invoice->get_email_cc());
380 380
 
381
-                $invoice->set_email( $hashed_inv_email );
382
-                $invoice->set_email_cc( $hashed_inv_email_cc );
383
-                $invoice->set_phone( '' );
384
-                $invoice->set_ip( $this->anonymize_data( $invoice->get_ip() ) );
385
-                $invoice->set_is_anonymized( 1 );
381
+                $invoice->set_email($hashed_inv_email);
382
+                $invoice->set_email_cc($hashed_inv_email_cc);
383
+                $invoice->set_phone('');
384
+                $invoice->set_ip($this->anonymize_data($invoice->get_ip()));
385
+                $invoice->set_is_anonymized(1);
386 386
 
387 387
                 /**
388 388
                  * Fires when anonymizing additional invoice data.
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
                  * @param WPInv_Invoice $invoice The invoice being anonymized.
392 392
                  * @param string        $action  The action being performed (anonymize or delete).
393 393
                  */
394
-                do_action( 'wpinv_anonymize_invoice_data', $invoice, $action );
394
+                do_action('wpinv_anonymize_invoice_data', $invoice, $action);
395 395
 
396 396
                 $invoice->save();
397 397
             } else {
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
             }
400 400
         }
401 401
 
402
-        return $this->log_deletion_action( $user_id, $invoices->invoices, $action );
402
+        return $this->log_deletion_action($user_id, $invoices->invoices, $action);
403 403
     }
404 404
 
405 405
     /**
@@ -411,11 +411,11 @@  discard block
 block discarded – undo
411 411
      * @param string $action   The action being performed (anonymize or delete).
412 412
      * @return bool True on success, false on failure.
413 413
      */
414
-    private function log_deletion_action( $user_id, $invoices, $action ) {
414
+    private function log_deletion_action($user_id, $invoices, $action) {
415 415
         global $wpdb;
416 416
 
417 417
         $table_name = $wpdb->prefix . 'getpaid_anonymization_logs';
418
-        $user_data  = get_userdata( $user_id );
418
+        $user_data  = get_userdata($user_id);
419 419
 
420 420
         $additional_info = array(
421 421
             'Username'      => $user_data ? $user_data->user_login : 'N/A',
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
             'First Name'    => $user_data ? $user_data->first_name : 'N/A',
425 425
             'Last Name'     => $user_data ? $user_data->last_name : 'N/A',
426 426
             'Registered'    => $user_data ? $user_data->user_registered : 'N/A',
427
-            'invoice_count' => count( $invoices ),
427
+            'invoice_count' => count($invoices),
428 428
         );
429 429
 
430 430
 
@@ -437,43 +437,43 @@  discard block
 block discarded – undo
437 437
          * @param array  $invoices        The invoices being processed.
438 438
          * @param string $action          The action being performed (anonymize or delete).
439 439
          */
440
-        $additional_info = apply_filters( 'wpinv_anonymization_log_additional_info', $additional_info, $user_id, $invoices, $action );
440
+        $additional_info = apply_filters('wpinv_anonymization_log_additional_info', $additional_info, $user_id, $invoices, $action);
441 441
 
442 442
         $data = array(
443 443
             'user_id'         => $user_id,
444
-            'action'          => sanitize_text_field( $action ),
444
+            'action'          => sanitize_text_field($action),
445 445
             'data_type'       => 'User Invoices',
446
-            'timestamp'       => current_time( 'mysql' ),
447
-            'additional_info' => wp_json_encode( $additional_info ),
446
+            'timestamp'       => current_time('mysql'),
447
+            'additional_info' => wp_json_encode($additional_info),
448 448
         );
449 449
 
450 450
         $format = array(
451
-            '%d',  // user_id
452
-            '%s',  // action
453
-            '%s',  // data_type
454
-            '%s',  // timestamp
455
-            '%s',  // additional_info
451
+            '%d', // user_id
452
+            '%s', // action
453
+            '%s', // data_type
454
+            '%s', // timestamp
455
+            '%s', // additional_info
456 456
         );
457 457
 
458
-        if ( ! empty( $user_id ) && ! empty( $action ) ) {
458
+        if (!empty($user_id) && !empty($action)) {
459 459
             $result = $wpdb->update(
460 460
                 $table_name,
461 461
                 $data,
462 462
                 array(
463 463
                     'user_id' => (int) $user_id,
464
-                    'action'  => sanitize_text_field( $action ),
464
+                    'action'  => sanitize_text_field($action),
465 465
                 ),
466 466
                 $format,
467
-                array( '%d', '%s' )
467
+                array('%d', '%s')
468 468
             );
469 469
 
470
-            if ( false === $result ) {
470
+            if (false === $result) {
471 471
                 // If update fails, try to insert.
472
-                $result = $wpdb->insert( $table_name, $data, $format );
472
+                $result = $wpdb->insert($table_name, $data, $format);
473 473
             }
474 474
 
475
-            if ( false === $result ) {
476
-                wpinv_error_log( sprintf( 'Failed to log anonymization action for user ID: %d. Error: %s', $user_id, $wpdb->last_error ) );
475
+            if (false === $result) {
476
+                wpinv_error_log(sprintf('Failed to log anonymization action for user ID: %d. Error: %s', $user_id, $wpdb->last_error));
477 477
                 return false;
478 478
             }
479 479
         }
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
          * @param string $action   The action being performed (anonymize or delete).
488 488
          * @param array  $data     The data that was inserted into the log.
489 489
          */
490
-        do_action( 'wpinv_after_log_deletion_action', $user_id, $invoices, $action, $data );
490
+        do_action('wpinv_after_log_deletion_action', $user_id, $invoices, $action, $data);
491 491
 
492 492
         return true;
493 493
     }
@@ -500,20 +500,20 @@  discard block
 block discarded – undo
500 500
      * @param int   $user_id  The ID of the user being erased.
501 501
      * @return array The modified response.
502 502
      */
503
-    public function handle_erasure_request( $response, $user_id ) {
504
-        if ( $this->has_active_subscriptions( $user_id ) ) {
505
-            $response['messages'][]    = esc_html__( 'User has active subscriptions. Data cannot be erased at this time.', 'invoicing' );
503
+    public function handle_erasure_request($response, $user_id) {
504
+        if ($this->has_active_subscriptions($user_id)) {
505
+            $response['messages'][]    = esc_html__('User has active subscriptions. Data cannot be erased at this time.', 'invoicing');
506 506
             $response['items_removed'] = false;
507
-        } elseif ( $this->has_paid_invoices( $user_id ) ) {
508
-            $retention_method = wpinv_get_option( 'data_retention_method', 'anonymize' );
509
-            if ( 'anonymize' === $retention_method ) {
510
-                $this->anonymize_user_data( $user_id );
511
-                $response['messages'][]     = esc_html__( 'User data has been anonymized due to existing paid invoices.', 'invoicing' );
507
+        } elseif ($this->has_paid_invoices($user_id)) {
508
+            $retention_method = wpinv_get_option('data_retention_method', 'anonymize');
509
+            if ('anonymize' === $retention_method) {
510
+                $this->anonymize_user_data($user_id);
511
+                $response['messages'][]     = esc_html__('User data has been anonymized due to existing paid invoices.', 'invoicing');
512 512
                 $response['items_removed']  = false;
513 513
                 $response['items_retained'] = true;
514 514
             } else {
515
-                $this->delete_user_data( $user_id );
516
-                $response['messages'][]     = esc_html__( 'User data has been deleted.', 'invoicing' );
515
+                $this->delete_user_data($user_id);
516
+                $response['messages'][]     = esc_html__('User data has been deleted.', 'invoicing');
517 517
                 $response['items_removed']  = true;
518 518
                 $response['items_retained'] = false;
519 519
             }
@@ -529,18 +529,18 @@  discard block
 block discarded – undo
529 529
      * @param string $email The email to hash.
530 530
      * @return string The hashed email.
531 531
      */
532
-    private function hash_email( $email ) {
532
+    private function hash_email($email) {
533 533
         $site_url = get_site_url();
534
-        $domain   = wp_parse_url( $site_url, PHP_URL_HOST );
534
+        $domain   = wp_parse_url($site_url, PHP_URL_HOST);
535 535
 
536
-        if ( empty( $domain ) ) {
536
+        if (empty($domain)) {
537 537
             return $email;
538 538
         }
539 539
 
540
-        $clean_email     = sanitize_email( strtolower( trim( $email ) ) );
541
-        $hash            = wp_hash( $clean_email );
542
-        $hash            = substr( $hash, 0, 20 );
543
-        $anonymized_email = sprintf( '%s@%s', $hash, $domain );
540
+        $clean_email     = sanitize_email(strtolower(trim($email)));
541
+        $hash            = wp_hash($clean_email);
542
+        $hash            = substr($hash, 0, 20);
543
+        $anonymized_email = sprintf('%s@%s', $hash, $domain);
544 544
 
545 545
         /**
546 546
          * Filters the anonymized email before returning.
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
          * @param string $anonymized_email The anonymized email address.
550 550
          * @param string $email            The original email address.
551 551
          */
552
-        return apply_filters( 'wpinv_anonymized_email', $anonymized_email, $email );
552
+        return apply_filters('wpinv_anonymized_email', $anonymized_email, $email);
553 553
     }
554 554
 
555 555
     /**
@@ -559,12 +559,12 @@  discard block
 block discarded – undo
559 559
      * @param string $data The data to anonymize.
560 560
      * @return string The anonymized data.
561 561
      */
562
-    private function anonymize_data( $data ) {
563
-        if ( empty( $data ) ) {
562
+    private function anonymize_data($data) {
563
+        if (empty($data)) {
564 564
             return '';
565 565
         }
566 566
 
567
-        return wp_privacy_anonymize_data( 'text', $data );
567
+        return wp_privacy_anonymize_data('text', $data);
568 568
     }
569 569
 
570 570
     /**
@@ -578,17 +578,17 @@  discard block
 block discarded – undo
578 578
     public function perform_data_retention_cleanup() {
579 579
         global $wpdb;
580 580
 
581
-        $retention_period = wpinv_get_option( 'data_retention_period', '3650' );
581
+        $retention_period = wpinv_get_option('data_retention_period', '3650');
582 582
 
583 583
         // If retention period is set to 'never', exit the function.
584
-        if ( 'never' === $retention_period ) {
584
+        if ('never' === $retention_period) {
585 585
             return;
586 586
         }
587 587
 
588 588
         $customers_table = $wpdb->prefix . 'getpaid_customers';
589 589
 
590 590
         // Calculate the cutoff date for data retention.
591
-        $cutoff_date = gmdate( 'Y-m-d', strtotime( "-$retention_period days" ) );
591
+        $cutoff_date = gmdate('Y-m-d', strtotime("-$retention_period days"));
592 592
 
593 593
         $expired_records = $wpdb->get_results(
594 594
             $wpdb->prepare(
@@ -603,18 +603,18 @@  discard block
 block discarded – undo
603 603
          * @since 2.8.22
604 604
          * @param array $expired_records Array of customer records to be processed.
605 605
          */
606
-        do_action( 'getpaid_data_retention_before_cleanup', $expired_records );
606
+        do_action('getpaid_data_retention_before_cleanup', $expired_records);
607 607
 
608
-        if ( ! empty( $expired_records ) ) {
608
+        if (!empty($expired_records)) {
609 609
             // Disable our custom user deletion handling.
610 610
             $this->handle_user_deletion = false;
611 611
 
612
-            foreach ( $expired_records as $record ) {
612
+            foreach ($expired_records as $record) {
613 613
                 // Delete associated invoices.
614
-                $this->ensure_invoice_anonymization( (int) $record->user_id, 'delete' );
614
+                $this->ensure_invoice_anonymization((int) $record->user_id, 'delete');
615 615
 
616 616
                 // Delete the user.
617
-                wp_delete_user( (int) $record->user_id );
617
+                wp_delete_user((int) $record->user_id);
618 618
 
619 619
                 /**
620 620
                  * Fires after processing each expired record during cleanup.
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
                  * @since 2.8.22
623 623
                  * @param object $record The customer record being processed.
624 624
                  */
625
-                do_action( 'getpaid_data_retention_process_record', $record );
625
+                do_action('getpaid_data_retention_process_record', $record);
626 626
             }
627 627
 
628 628
             // Re-enable our custom user deletion handling.
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
              * @since 2.8.22
635 635
              * @param array $expired_records Array of customer records that were processed.
636 636
              */
637
-            do_action( 'getpaid_data_retention_after_cleanup', $expired_records );
637
+            do_action('getpaid_data_retention_after_cleanup', $expired_records);
638 638
         }
639 639
 
640 640
         /**
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
          * @param int $retention_period The current retention period in years.
645 645
          * @param string $cutoff_date The cutoff date used for identifying expired records.
646 646
          */
647
-        do_action( 'getpaid_data_retention_cleanup_complete', $retention_period, $cutoff_date );
647
+        do_action('getpaid_data_retention_cleanup_complete', $retention_period, $cutoff_date);
648 648
     }
649 649
 
650 650
     /**
@@ -657,7 +657,7 @@  discard block
 block discarded – undo
657 657
 
658 658
         // Redirect after deletion.
659 659
         $redirect_page = home_url();
660
-        wp_safe_redirect( $redirect_page );
660
+        wp_safe_redirect($redirect_page);
661 661
         exit();
662 662
     }
663 663
 }
664 664
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin-setup-wizard.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @version     2.4.0
11 11
  * @info        GetPaid Setup Wizard.
12 12
  */
13
-defined( 'ABSPATH' ) || exit;
13
+defined('ABSPATH') || exit;
14 14
 
15 15
 /**
16 16
  * GetPaid_Admin_Setup_Wizard class.
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
 	 */
45 45
 	public function __construct() {
46 46
 
47
-		if ( apply_filters( 'getpaid_enable_setup_wizard', true ) && wpinv_current_user_can_manage_invoicing() ) {
48
-			add_action( 'admin_menu', array( $this, 'add_menu' ) );
49
-			add_action( 'current_screen', array( $this, 'setup_wizard' ) );
50
-			add_action( 'admin_init', array( $this, 'remove_deprecated_functions' ) );
47
+		if (apply_filters('getpaid_enable_setup_wizard', true) && wpinv_current_user_can_manage_invoicing()) {
48
+			add_action('admin_menu', array($this, 'add_menu'));
49
+			add_action('current_screen', array($this, 'setup_wizard'));
50
+			add_action('admin_init', array($this, 'remove_deprecated_functions'));
51 51
 		}
52 52
 
53 53
 	}
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 * @since 2.4.0
59 59
 	 */
60 60
 	public function add_menu() {
61
-		add_dashboard_page( '', '', wpinv_get_capability(), 'gp-setup', '' );
61
+		add_dashboard_page('', '', wpinv_get_capability(), 'gp-setup', '');
62 62
 	}
63 63
 
64 64
 	/**
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	 */
69 69
 	public function setup_wizard() {
70 70
 
71
-		if ( isset( $_GET['page'] ) && 'gp-setup' === $_GET['page'] ) {
71
+		if (isset($_GET['page']) && 'gp-setup' === $_GET['page']) {
72 72
 			$this->setup_globals();
73 73
 			$this->maybe_save_current_step();
74 74
 			$this->display_wizard();
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	public function remove_deprecated_functions() {
81 81
 		// removes deprecated warnings from page
82 82
 		remove_action('admin_print_styles', 'print_emoji_styles');
83
-		remove_action( 'admin_head', 'wp_admin_bar_header' );
83
+		remove_action('admin_head', 'wp_admin_bar_header');
84 84
 	}
85 85
 
86 86
 	/**
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 	 * @since 2.4.0
102 102
 	 */
103 103
 	protected function maybe_save_current_step() {
104
-		if ( ! empty( $_POST['save_step'] ) && is_callable( $this->steps[ $this->step ]['handler'] ) ) {
105
-			call_user_func( $this->steps[ $this->step ]['handler'], $this );
104
+		if (!empty($_POST['save_step']) && is_callable($this->steps[$this->step]['handler'])) {
105
+			call_user_func($this->steps[$this->step]['handler'], $this);
106 106
 		}
107 107
 	}
108 108
 
@@ -117,44 +117,44 @@  discard block
 block discarded – undo
117 117
 		$steps = array(
118 118
 
119 119
 			'introduction'     => array(
120
-				'name'    => __( 'Introduction', 'invoicing' ),
121
-				'view'    => array( $this, 'setup_introduction' ),
120
+				'name'    => __('Introduction', 'invoicing'),
121
+				'view'    => array($this, 'setup_introduction'),
122 122
 				'handler' => '',
123 123
 			),
124 124
 
125 125
 			'business_details' => array(
126
-				'name'    => __( 'Business Details', 'invoicing' ),
127
-				'view'    => array( $this, 'setup_business' ),
126
+				'name'    => __('Business Details', 'invoicing'),
127
+				'view'    => array($this, 'setup_business'),
128 128
 				'handler' => '',
129 129
 			),
130 130
 
131 131
 			'currency'         => array(
132
-				'name'    => __( 'Currency', 'invoicing' ),
133
-				'view'    => array( $this, 'setup_currency' ),
132
+				'name'    => __('Currency', 'invoicing'),
133
+				'view'    => array($this, 'setup_currency'),
134 134
 				'handler' => '',
135 135
 			),
136 136
 
137 137
 			'payments'         => array(
138
-				'name'    => __( 'Payment Gateways', 'invoicing' ),
139
-				'view'    => array( $this, 'setup_payments' ),
140
-				'handler' => array( $this, 'setup_payments_save' ),
138
+				'name'    => __('Payment Gateways', 'invoicing'),
139
+				'view'    => array($this, 'setup_payments'),
140
+				'handler' => array($this, 'setup_payments_save'),
141 141
 			),
142 142
 
143 143
 			'recommend'        => array(
144
-				'name'    => __( 'Recommend', 'invoicing' ),
145
-				'view'    => array( $this, 'setup_recommend' ),
144
+				'name'    => __('Recommend', 'invoicing'),
145
+				'view'    => array($this, 'setup_recommend'),
146 146
 				'handler' => '',
147 147
 			),
148 148
 
149 149
 			'next_steps'       => array(
150
-				'name'    => __( 'Get Paid', 'invoicing' ),
151
-				'view'    => array( $this, 'setup_ready' ),
150
+				'name'    => __('Get Paid', 'invoicing'),
151
+				'view'    => array($this, 'setup_ready'),
152 152
 				'handler' => '',
153 153
 			),
154 154
 
155 155
 		);
156 156
 
157
-		return apply_filters( 'getpaid_setup_wizard_steps', $steps );
157
+		return apply_filters('getpaid_setup_wizard_steps', $steps);
158 158
 
159 159
 	}
160 160
 
@@ -165,8 +165,8 @@  discard block
 block discarded – undo
165 165
 	 * @return string
166 166
 	 */
167 167
 	protected function get_current_step() {
168
-		$step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : '';
169
-		return ! empty( $step ) && in_array( $step, array_keys( $this->steps ) ) ? $step : current( array_keys( $this->steps ) );
168
+		$step = isset($_GET['step']) ? sanitize_key($_GET['step']) : '';
169
+		return !empty($step) && in_array($step, array_keys($this->steps)) ? $step : current(array_keys($this->steps));
170 170
 	}
171 171
 
172 172
 	/**
@@ -179,8 +179,8 @@  discard block
 block discarded – undo
179 179
 
180 180
 		$previous = false;
181 181
 		$current  = $this->step;
182
-		foreach ( array_keys( $this->steps ) as $step ) {
183
-			if ( $current === $step ) {
182
+		foreach (array_keys($this->steps) as $step) {
183
+			if ($current === $step) {
184 184
 				return $previous;
185 185
 			}
186 186
 
@@ -200,13 +200,13 @@  discard block
 block discarded – undo
200 200
 
201 201
 		$on_current = false;
202 202
 		$current    = $this->step;
203
-		foreach ( array_keys( $this->steps ) as $step ) {
203
+		foreach (array_keys($this->steps) as $step) {
204 204
 
205
-			if ( $on_current ) {
205
+			if ($on_current) {
206 206
 				return $step;
207 207
 			}
208 208
 
209
-			if ( $current === $step ) {
209
+			if ($current === $step) {
210 210
 				return $on_current = true;
211 211
 			}
212 212
 }
@@ -234,8 +234,8 @@  discard block
 block discarded – undo
234 234
 		$steps     = $this->steps;
235 235
 		$current   = $this->step;
236 236
 		$next_step = $this->next_step;
237
-		array_shift( $steps );
238
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-header.php';
237
+		array_shift($steps);
238
+		include plugin_dir_path(__FILE__) . 'views/wizard-header.php';
239 239
 	}
240 240
 
241 241
 	/**
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 		?>
248 248
 			<div class="gp-setup-content rowx mw-100 text-center mb-3">
249 249
 				<div class="col-12 col-md-5 m-auto">
250
-					<?php call_user_func( $this->steps[ $this->step ]['view'], $this ); ?>
250
+					<?php call_user_func($this->steps[$this->step]['view'], $this); ?>
251 251
 				</div>
252 252
 			</div>
253 253
 		<?php
@@ -260,10 +260,10 @@  discard block
 block discarded – undo
260 260
 	 */
261 261
 	public function display_footer() {
262 262
 
263
-		if ( isset( $_GET['step'] ) ) {
264
-			$label    = $this->step == 'next_steps' ? __( 'Return to the WordPress Dashboard', 'invoicing' ) : __( 'Skip this step', 'invoicing' );
263
+		if (isset($_GET['step'])) {
264
+			$label = $this->step == 'next_steps' ? __('Return to the WordPress Dashboard', 'invoicing') : __('Skip this step', 'invoicing');
265 265
 
266
-			echo '<p class="gd-return-to-dashboard-wrap"> <a href="' . esc_url( $this->get_next_step_link() ) . '" class="gd-return-to-dashboard btn btn-link d-block text-muted">' . esc_html( $label ) . '</a></p>';
266
+			echo '<p class="gd-return-to-dashboard-wrap"> <a href="' . esc_url($this->get_next_step_link()) . '" class="gd-return-to-dashboard btn btn-link d-block text-muted">' . esc_html($label) . '</a></p>';
267 267
 		}
268 268
 
269 269
 		echo '</body></html>';
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	 */
277 277
 	public function setup_introduction() {
278 278
 		$next_url = $this->get_next_step_link();
279
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-introduction.php';
279
+		include plugin_dir_path(__FILE__) . 'views/wizard-introduction.php';
280 280
 	}
281 281
 
282 282
 	/**
@@ -289,22 +289,22 @@  discard block
 block discarded – undo
289 289
 	 *                      Empty string on failure.
290 290
 	 * @since 3.0.0
291 291
 	 */
292
-	public function get_next_step_link( $step = '' ) {
293
-		if ( ! $step ) {
292
+	public function get_next_step_link($step = '') {
293
+		if (!$step) {
294 294
 			$step = $this->step;
295 295
 		}
296 296
 
297
-		$keys = array_keys( $this->steps );
298
-		if ( end( $keys ) === $step ) {
297
+		$keys = array_keys($this->steps);
298
+		if (end($keys) === $step) {
299 299
 			return admin_url();
300 300
 		}
301 301
 
302
-		$step_index = array_search( $step, $keys );
303
-		if ( false === $step_index ) {
302
+		$step_index = array_search($step, $keys);
303
+		if (false === $step_index) {
304 304
 			return '';
305 305
 		}
306 306
 
307
-		return remove_query_arg( 'settings-updated', add_query_arg( 'step', $keys[ $step_index + 1 ] ) );
307
+		return remove_query_arg('settings-updated', add_query_arg('step', $keys[$step_index + 1]));
308 308
 	}
309 309
 
310 310
 	/**
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 		$wizard   = $this;
318 318
 		$page     = 'wpinv_settings_general_main';
319 319
 		$section  = 'wpinv_settings_general_main';
320
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-settings.php';
320
+		include plugin_dir_path(__FILE__) . 'views/wizard-settings.php';
321 321
 	}
322 322
 
323 323
 	/**
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 		$wizard   = $this;
331 331
 		$page     = 'wpinv_settings_general_currency_section';
332 332
 		$section  = 'wpinv_settings_general_currency_section';
333
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-settings.php';
333
+		include plugin_dir_path(__FILE__) . 'views/wizard-settings.php';
334 334
 	}
335 335
 
336 336
 	/**
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 	public function setup_recommend() {
342 342
 		$next_url            = $this->get_next_step_link();
343 343
 		$recommended_plugins = self::get_recommend_wp_plugins();
344
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-plugins.php';
344
+		include plugin_dir_path(__FILE__) . 'views/wizard-plugins.php';
345 345
 	}
346 346
 
347 347
 	/**
@@ -355,21 +355,21 @@  discard block
 block discarded – undo
355 355
 				'url'  => 'https://wordpress.org/plugins/ayecode-connect/',
356 356
 				'slug' => 'ayecode-connect',
357 357
 				'name' => 'AyeCode Connect',
358
-				'desc' => __( 'Documentation and Support from within your WordPress admin.', 'invoicing' ),
358
+				'desc' => __('Documentation and Support from within your WordPress admin.', 'invoicing'),
359 359
 			),
360 360
 			'invoicing-quotes' => array(
361 361
 				'file' => 'invoicing-quotes/wpinv-quote.php',
362 362
 				'url'  => 'https://wordpress.org/plugins/invoicing-quotes/',
363 363
 				'slug' => 'invoicing-quotes',
364 364
 				'name' => 'Customer Quotes',
365
-				'desc' => __( 'Create & Send Quotes to Customers and have them accept and pay.', 'invoicing' ),
365
+				'desc' => __('Create & Send Quotes to Customers and have them accept and pay.', 'invoicing'),
366 366
 			),
367 367
 			'userswp'          => array(
368 368
 				'file' => 'userswp/userswp.php',
369 369
 				'url'  => 'https://wordpress.org/plugins/userswp/',
370 370
 				'slug' => 'userswp',
371 371
 				'name' => 'UsersWP',
372
-				'desc' => __( 'Frontend user login and registration as well as slick profile pages.', 'invoicing' ),
372
+				'desc' => __('Frontend user login and registration as well as slick profile pages.', 'invoicing'),
373 373
 			),
374 374
 		);
375 375
 	}
@@ -381,7 +381,7 @@  discard block
 block discarded – undo
381 381
 	 */
382 382
 	public function setup_payments() {
383 383
 		$next_url = $this->get_next_step_link();
384
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-gateways.php';
384
+		include plugin_dir_path(__FILE__) . 'views/wizard-gateways.php';
385 385
 	}
386 386
 
387 387
 	/**
@@ -392,16 +392,16 @@  discard block
 block discarded – undo
392 392
 	 * @since 2.0.0
393 393
 	 */
394 394
 	public function setup_payments_save() {
395
-		check_admin_referer( 'getpaid-setup-wizard', 'getpaid-setup-wizard' );
396
-		wpinv_update_option( 'manual_active', ! empty( $_POST['enable-manual-gateway'] ) );
395
+		check_admin_referer('getpaid-setup-wizard', 'getpaid-setup-wizard');
396
+		wpinv_update_option('manual_active', !empty($_POST['enable-manual-gateway']));
397 397
 
398
-		if ( ! empty( $_POST['paypal-email'] ) ) {
399
-			wpinv_update_option( 'paypal_email', sanitize_email( $_POST['paypal-email'] ) );
400
-			wpinv_update_option( 'paypal_active', 1 );
401
-			wpinv_update_option( 'paypal_sandbox', 0 );
398
+		if (!empty($_POST['paypal-email'])) {
399
+			wpinv_update_option('paypal_email', sanitize_email($_POST['paypal-email']));
400
+			wpinv_update_option('paypal_active', 1);
401
+			wpinv_update_option('paypal_sandbox', 0);
402 402
 		}
403 403
 
404
-		wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
404
+		wp_redirect(esc_url_raw($this->get_next_step_link()));
405 405
 		exit;
406 406
 	}
407 407
 
@@ -411,7 +411,7 @@  discard block
 block discarded – undo
411 411
 	 * @since 2.0.0
412 412
 	 */
413 413
 	public function setup_ready() {
414
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-thank-you.php';
414
+		include plugin_dir_path(__FILE__) . 'views/wizard-thank-you.php';
415 415
 	}
416 416
 
417 417
 }
Please login to merge, or discard this patch.
vendor/ayecode/wp-super-duper/includes/class-super-duper-bricks-element.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -1,20 +1,20 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 
4
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
+if (!defined('ABSPATH')) exit; // Exit if accessed directly
5 5
 
6 6
 
7 7
 class Super_Duper_Bricks_Element extends \Bricks\Element {
8 8
 
9 9
 	public $widget;
10 10
 
11
-	public function __construct( $element = null ) {
11
+	public function __construct($element = null) {
12 12
 
13 13
 
14 14
 		$block_icon = !empty($this->widget->options['block-icon']) ? $this->widget->options['block-icon'] : '';
15 15
 
16 16
 
17
-		$this->category = !empty($this->widget->options['textdomain']) ? esc_attr( $this->widget->options['textdomain'] ) : 'Super Duper';
17
+		$this->category = !empty($this->widget->options['textdomain']) ? esc_attr($this->widget->options['textdomain']) : 'Super Duper';
18 18
 		$this->name     = $this->widget->id_base;
19 19
 		$this->icon     = (strpos($block_icon, 'fa') === 0) ? esc_attr($this->widget->options['block-icon']) : 'fas fa-globe-americas';
20 20
 
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
 	 * @return array|string|string[]|null
28 28
 	 */
29 29
 	public function get_label() {
30
-		$escaped_text = esc_attr( $this->widget->name );
31
-		return str_replace( ' &gt; ', ' > ', $escaped_text ); // keep our > but have it safe
30
+		$escaped_text = esc_attr($this->widget->name);
31
+		return str_replace(' &gt; ', ' > ', $escaped_text); // keep our > but have it safe
32 32
 	}
33 33
 
34 34
 	/**
@@ -54,19 +54,19 @@  discard block
 block discarded – undo
54 54
 		$args = $this->sd_get_arguments();
55 55
 
56 56
 		$groups = array();
57
-		if(!empty($args)) {
57
+		if (!empty($args)) {
58 58
 			foreach ($args as $k => $v) {
59
-				$g_slug = !empty($v['group']) ? sanitize_title( $v['group'] ) : '';
60
-				if($g_slug && empty($groups[$g_slug])) {
59
+				$g_slug = !empty($v['group']) ? sanitize_title($v['group']) : '';
60
+				if ($g_slug && empty($groups[$g_slug])) {
61 61
 					$groups[$g_slug] = array(
62
-						'title' => esc_html( $v['group'] ),
62
+						'title' => esc_html($v['group']),
63 63
 						'tab' => 'content',
64 64
 					);
65 65
 				}
66 66
 			}
67 67
 		}
68 68
 
69
-		if(!empty($groups)) {
69
+		if (!empty($groups)) {
70 70
 			$this->control_groups = $this->control_groups + $groups;
71 71
 		}
72 72
 
@@ -80,15 +80,15 @@  discard block
 block discarded – undo
80 80
 	public function sd_get_arguments() {
81 81
 		$args = $this->widget->set_arguments();
82 82
 
83
-		$widget_options = ! empty( $this->widget->options ) ? $this->widget->options : array();
84
-		$widget_instance = ! empty( $this->widget->instance ) ? $this->widget->instance : array();
83
+		$widget_options = !empty($this->widget->options) ? $this->widget->options : array();
84
+		$widget_instance = !empty($this->widget->instance) ? $this->widget->instance : array();
85 85
 
86
-		$args = apply_filters( 'wp_super_duper_arguments', $args, $widget_options, $widget_instance );
86
+		$args = apply_filters('wp_super_duper_arguments', $args, $widget_options, $widget_instance);
87 87
 
88 88
 		$arg_keys_subtract = $this->sd_remove_arguments();
89 89
 
90
-		if ( ! empty( $arg_keys_subtract ) ) {
91
-			foreach($arg_keys_subtract as $key ){
90
+		if (!empty($arg_keys_subtract)) {
91
+			foreach ($arg_keys_subtract as $key) {
92 92
 				unset($args[$key]);
93 93
 			}
94 94
 		}
@@ -103,18 +103,18 @@  discard block
 block discarded – undo
103 103
 	 * @return void
104 104
 	 */
105 105
 	public function render() {
106
-		$settings = $this->sd_maybe_convert_values( $this->settings );
106
+		$settings = $this->sd_maybe_convert_values($this->settings);
107 107
 
108 108
 		// Set the AyeCode UI calss on the wrapper
109
-		$this->set_attribute( '_root', 'class', 'bsui' );
109
+		$this->set_attribute('_root', 'class', 'bsui');
110 110
 
111 111
 		// We might need to add a placeholder here for previews.
112 112
 
113
-		do_action( 'super_duper_before_render_bricks_element', $settings, $this->widget, $this );
113
+		do_action('super_duper_before_render_bricks_element', $settings, $this->widget, $this);
114 114
 
115 115
 		// Add the bricks attributes to wrapper
116
-		echo "<div {$this->render_attributes( '_root' )}>";
117
-		echo $this->widget->output( $settings );
116
+		echo "<div {$this->render_attributes('_root')}>";
117
+		echo $this->widget->output($settings);
118 118
 		echo '</div>';
119 119
 	}
120 120
 
@@ -124,12 +124,12 @@  discard block
 block discarded – undo
124 124
 	 * @param $settings
125 125
 	 * @return mixed
126 126
 	 */
127
-	public function sd_maybe_convert_values( $settings ) {
127
+	public function sd_maybe_convert_values($settings) {
128 128
 
129 129
 
130 130
 		if (!empty($settings)) {
131
-			foreach( $settings as $k => $v ) {
132
-				if(is_array($v)) {
131
+			foreach ($settings as $k => $v) {
132
+				if (is_array($v)) {
133 133
 					$value = '';
134 134
 					// is color
135 135
 					if (isset($v['hex'])) {
@@ -161,40 +161,40 @@  discard block
 block discarded – undo
161 161
 
162 162
 		$args = $this->sd_get_arguments();
163 163
 
164
-		if ( ! empty( $args ) ) {
165
-			foreach ( $args as $key => $arg ) {
164
+		if (!empty($args)) {
165
+			foreach ($args as $key => $arg) {
166 166
 				// convert title
167
-				if ( ! empty( $arg['title'] ) ) {
167
+				if (!empty($arg['title'])) {
168 168
 					$arg['label'] = $arg['title'];
169
-					unset( $arg['title'] );
169
+					unset($arg['title']);
170 170
 				}
171 171
 
172 172
 				// set fields not to use dynamic data
173 173
 				$arg['hasDynamicData'] = false;
174 174
 
175
-				if ( ! empty( $arg['group'] ) ) {
176
-					$arg['group'] =  sanitize_title( $arg['group'] );
175
+				if (!empty($arg['group'])) {
176
+					$arg['group'] = sanitize_title($arg['group']);
177 177
 				}
178 178
 
179 179
 				$arg['rerender'] = true;
180 180
 
181 181
 				// required
182
-				if( ! empty( $arg['element_require'] ) ) {
183
-					$arg['required'] = $this->sd_convert_required( $arg['element_require'] );
184
-					unset( $arg['element_require'] );
182
+				if (!empty($arg['element_require'])) {
183
+					$arg['required'] = $this->sd_convert_required($arg['element_require']);
184
+					unset($arg['element_require']);
185 185
 				}
186 186
 
187 187
 				// icons
188
-				if ( 'icon' === $key ) {
188
+				if ('icon' === $key) {
189 189
 					$arg['type'] = 'icon';
190 190
 				}
191 191
 
192 192
 				// Bricks don't render dropdown when first option key is 0.
193
-				if ( in_array( $key, array( 'zoom', 'mapzoom' ) ) && ! empty( $arg['options'] ) && is_array( $arg['options'] ) && ( $option_keys = array_keys( $arg['options'] ) ) ) {
193
+				if (in_array($key, array('zoom', 'mapzoom')) && !empty($arg['options']) && is_array($arg['options']) && ($option_keys = array_keys($arg['options']))) {
194 194
 					// Move first element to last.
195
-					if ( $option_keys[0] === 0 || $option_keys[0] === '0' ) {
195
+					if ($option_keys[0] === 0 || $option_keys[0] === '0') {
196 196
 						$options = $arg['options'];
197
-						unset( $arg['options'][0] );
197
+						unset($arg['options'][0]);
198 198
 						$arg['options'][0] = $options[0];
199 199
 					}
200 200
 				}
@@ -265,10 +265,10 @@  discard block
 block discarded – undo
265 265
 /**
266 266
  * This implements the desktop, tablet and mobile breakpoints views with our fields that are hidden on these types and adda the icon after the label to show which it applies to.
267 267
  */
268
-add_action( 'wp_enqueue_scripts', function() {
268
+add_action('wp_enqueue_scripts', function() {
269 269
 
270 270
 	// Check if we're in the Bricks Editor
271
-	if ( isset( $_GET['bricks'] ) && $_GET['bricks'] && bricks_is_builder_main() ) {
271
+	if (isset($_GET['bricks']) && $_GET['bricks'] && bricks_is_builder_main()) {
272 272
 		// Add inline script to the 'bricks-builder' script
273 273
 		wp_add_inline_script(
274 274
 			'bricks-builder',
Please login to merge, or discard this patch.
includes/admin/class-wpinv-subscriptions-list-table.php 1 patch
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -3,11 +3,11 @@  discard block
 block discarded – undo
3 3
  * Displays a list of all subscriptions rules
4 4
  */
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if (!defined('ABSPATH')) {
7 7
 exit;
8 8
 }
9 9
 
10
-if ( ! class_exists( 'WP_List_Table' ) ) {
10
+if (!class_exists('WP_List_Table')) {
11 11
 	include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
12 12
 }
13 13
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 
81 81
 		$this->prepare_query();
82 82
 
83
-		$this->base_url = remove_query_arg( 'status' );
83
+		$this->base_url = remove_query_arg('status');
84 84
 
85 85
 	}
86 86
 
@@ -93,13 +93,13 @@  discard block
 block discarded – undo
93 93
 		$query = array(
94 94
 			'number'      => $this->per_page,
95 95
 			'paged'       => $this->get_paged(),
96
-			'status'      => ( isset( $_GET['status'] ) && array_key_exists( $_GET['status'], getpaid_get_subscription_statuses() ) ) ? sanitize_text_field( $_GET['status'] ) : 'all',
97
-			'orderby'     => ( isset( $_GET['orderby'] ) ) ? sanitize_text_field( $_GET['orderby'] ) : 'id',
98
-			'order'       => ( isset( $_GET['order'] ) ) ? sanitize_text_field( $_GET['order'] ) : 'DESC',
96
+			'status'      => (isset($_GET['status']) && array_key_exists($_GET['status'], getpaid_get_subscription_statuses())) ? sanitize_text_field($_GET['status']) : 'all',
97
+			'orderby'     => (isset($_GET['orderby'])) ? sanitize_text_field($_GET['orderby']) : 'id',
98
+			'order'       => (isset($_GET['order'])) ? sanitize_text_field($_GET['order']) : 'DESC',
99 99
 			'customer_in' => $this->get_user_in(),
100 100
 		);
101 101
 
102
-		if ( is_array( $query['customer_in'] ) && empty( $query['customer_in'] ) ) {
102
+		if (is_array($query['customer_in']) && empty($query['customer_in'])) {
103 103
 			$this->total_count         = 0;
104 104
 			$this->current_total_count = 0;
105 105
 			$this->items               = array();
@@ -108,15 +108,15 @@  discard block
 block discarded – undo
108 108
 		}
109 109
 
110 110
 		// Prepare class properties.
111
-		$this->query               = new GetPaid_Subscriptions_Query( $query );
111
+		$this->query               = new GetPaid_Subscriptions_Query($query);
112 112
 		$this->total_count         = $this->query->get_total();
113 113
 		$this->current_total_count = $this->query->get_total();
114 114
 		$this->items               = $this->query->get_results();
115
-		$this->status_counts       = getpaid_get_subscription_status_counts( $query );
115
+		$this->status_counts       = getpaid_get_subscription_status_counts($query);
116 116
 
117
-		if ( 'all' != $query['status'] ) {
118
-			unset( $query['status'] );
119
-			$this->total_count   = getpaid_get_subscriptions( $query, 'count' );
117
+		if ('all' != $query['status']) {
118
+			unset($query['status']);
119
+			$this->total_count = getpaid_get_subscriptions($query, 'count');
120 120
 		}
121 121
 
122 122
 	}
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
 	public function get_user_in() {
129 129
 
130 130
 		// Abort if no user.
131
-		if ( empty( $_GET['s'] ) ) {
131
+		if (empty($_GET['s'])) {
132 132
 			return null;
133 133
 		}
134 134
 
135 135
 		// Or invalid user.
136
-		$user = wp_unslash( sanitize_text_field( $_REQUEST['s'] ) );
136
+		$user = wp_unslash(sanitize_text_field($_REQUEST['s']));
137 137
 
138
-		if ( empty( $user ) ) {
138
+		if (empty($user)) {
139 139
 			return null;
140 140
 		}
141 141
 
@@ -164,26 +164,26 @@  discard block
 block discarded – undo
164 164
 	 */
165 165
 	public function get_views() {
166 166
 
167
-		$current  = isset( $_GET['status'] ) ? sanitize_text_field( $_GET['status'] ) : 'all';
167
+		$current  = isset($_GET['status']) ? sanitize_text_field($_GET['status']) : 'all';
168 168
 		$views    = array(
169 169
 
170 170
 			'all' => sprintf(
171 171
 				'<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
172
-				esc_url( add_query_arg( 'status', false, $this->base_url ) ),
172
+				esc_url(add_query_arg('status', false, $this->base_url)),
173 173
 				$current === 'all' ? ' class="current"' : '',
174
-				__( 'All', 'invoicing' ),
174
+				__('All', 'invoicing'),
175 175
 				$this->total_count
176 176
 			),
177 177
 
178 178
 		);
179 179
 
180
-		foreach ( array_filter( $this->status_counts ) as $status => $count ) {
180
+		foreach (array_filter($this->status_counts) as $status => $count) {
181 181
 
182
-			$views[ $status ] = sprintf(
182
+			$views[$status] = sprintf(
183 183
 				'<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
184
-				esc_url( add_query_arg( 'status', urlencode( $status ), $this->base_url ) ),
184
+				esc_url(add_query_arg('status', urlencode($status), $this->base_url)),
185 185
 				$current === $status ? ' class="current"' : '',
186
-				esc_html( getpaid_get_subscription_status_label( $status ) ),
186
+				esc_html(getpaid_get_subscription_status_label($status)),
187 187
 				$count
188 188
 			);
189 189
 
@@ -200,8 +200,8 @@  discard block
 block discarded – undo
200 200
 	 * @since       1.0.0
201 201
 	 * @return      string
202 202
 	 */
203
-	public function column_default( $item, $column_name ) {
204
-		return apply_filters( "getpaid_subscriptions_table_column_$column_name", $item->$column_name );
203
+	public function column_default($item, $column_name) {
204
+		return apply_filters("getpaid_subscriptions_table_column_$column_name", $item->$column_name);
205 205
 	}
206 206
 
207 207
 	/**
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
 	 * @param WPInv_Subscription $item
211 211
 	 * @return string
212 212
 	 */
213
-	public function column_cb( $item ) {
214
-		return sprintf( '<input type="checkbox" name="id[]" value="%s" />', esc_html( $item->get_id() ) );
213
+	public function column_cb($item) {
214
+		return sprintf('<input type="checkbox" name="id[]" value="%s" />', esc_html($item->get_id()));
215 215
 	}
216 216
 
217 217
 	/**
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
 	 * @since       1.0.0
222 222
 	 * @return      string
223 223
 	 */
224
-	public function column_status( $item ) {
225
-		$extra = $item->has_status( 'expired' ) ? '<small class="text-muted d-block">' . wp_sprintf( _x( 'On: %s', 'Expired On:', 'invoicing' ), getpaid_format_date_value( $item->get_expiration() ) ) . '</small>' : '';
224
+	public function column_status($item) {
225
+		$extra = $item->has_status('expired') ? '<small class="text-muted d-block">' . wp_sprintf(_x('On: %s', 'Expired On:', 'invoicing'), getpaid_format_date_value($item->get_expiration())) . '</small>' : '';
226 226
 
227 227
 		return $item->get_status_label_html() . $extra;
228 228
 	}
@@ -234,26 +234,26 @@  discard block
 block discarded – undo
234 234
 	 * @since       1.0.0
235 235
 	 * @return      string
236 236
 	 */
237
-	public function column_subscription( $item ) {
237
+	public function column_subscription($item) {
238 238
 
239
-		$username = __( '(Missing User)', 'invoicing' );
239
+		$username = __('(Missing User)', 'invoicing');
240 240
 
241
-		$user = get_userdata( $item->get_customer_id() );
241
+		$user = get_userdata($item->get_customer_id());
242 242
 		$capabilities = wpinv_current_user_can_manage_invoicing();
243 243
 
244
-		if ( $user ) {
244
+		if ($user) {
245 245
 			$username = sprintf(
246 246
 				'<a href="user-edit.php?user_id=%s">%s</a>',
247
-				absint( $user->ID ),
248
-				! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
247
+				absint($user->ID),
248
+				!empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email)
249 249
 			);
250 250
 		}
251 251
 
252 252
 		// translators: $1: is opening link, $2: is subscription id number, $3: is closing link tag, $4: is user's name
253 253
 		$column_content = sprintf(
254
-			_x( '%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing' ),
255
-			'<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $item->get_id() ) ) ) . '">',
256
-			'<strong>' . esc_attr( $item->get_id() ) . '</strong>',
254
+			_x('%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing'),
255
+			'<a href="' . esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($item->get_id()))) . '">',
256
+			'<strong>' . esc_attr($item->get_id()) . '</strong>',
257 257
 			'</a>',
258 258
 			$username
259 259
 		);
@@ -261,18 +261,18 @@  discard block
 block discarded – undo
261 261
 		$row_actions = array();
262 262
 
263 263
 		// View subscription.
264
-		$view_url    = esc_url( add_query_arg( 'id', $item->get_id(), admin_url( 'admin.php?page=wpinv-subscriptions' ) ) );
265
-		$row_actions['view'] = '<a href="' . $view_url . '">' . __( 'View Subscription', 'invoicing' ) . '</a>';
264
+		$view_url    = esc_url(add_query_arg('id', $item->get_id(), admin_url('admin.php?page=wpinv-subscriptions')));
265
+		$row_actions['view'] = '<a href="' . $view_url . '">' . __('View Subscription', 'invoicing') . '</a>';
266 266
 
267 267
 		// View invoice.
268
-		$invoice = get_post( $item->get_parent_invoice_id() );
268
+		$invoice = get_post($item->get_parent_invoice_id());
269 269
 
270
-		if ( ! empty( $invoice ) ) {
271
-			$invoice_url            = get_edit_post_link( $invoice );
272
-			$row_actions['invoice'] = '<a href="' . $invoice_url . '">' . __( 'View Invoice', 'invoicing' ) . '</a>';
270
+		if (!empty($invoice)) {
271
+			$invoice_url            = get_edit_post_link($invoice);
272
+			$row_actions['invoice'] = '<a href="' . $invoice_url . '">' . __('View Invoice', 'invoicing') . '</a>';
273 273
 		}
274 274
 
275
-		$delete_url            = esc_url(
275
+		$delete_url = esc_url(
276 276
 			wp_nonce_url(
277 277
 				add_query_arg(
278 278
 					array(
@@ -284,15 +284,15 @@  discard block
 block discarded – undo
284 284
 				'getpaid-nonce'
285 285
 			)
286 286
 		);
287
-		$row_actions['delete'] = '<a class="text-danger" href="' . $delete_url . '">' . __( 'Delete Subscription', 'invoicing' ) . '</a>';
287
+		$row_actions['delete'] = '<a class="text-danger" href="' . $delete_url . '">' . __('Delete Subscription', 'invoicing') . '</a>';
288 288
 
289
-		if ( ! $capabilities ) {
289
+		if (!$capabilities) {
290 290
 			$row_actions = array();
291 291
 		}
292 292
 
293
-		$row_actions = $this->row_actions( apply_filters( 'getpaid_subscription_table_row_actions', $row_actions, $item ) );
293
+		$row_actions = $this->row_actions(apply_filters('getpaid_subscription_table_row_actions', $row_actions, $item));
294 294
 
295
-		return "<strong>$column_content</strong>" . $this->column_amount( $item ) . $row_actions;
295
+		return "<strong>$column_content</strong>" . $this->column_amount($item) . $row_actions;
296 296
 	}
297 297
 
298 298
 	/**
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
 	 * @since       1.0.0
303 303
 	 * @return      string
304 304
 	 */
305
-	public function column_renewal_date( $item ) {
306
-		if ( $item->has_status( 'active trialling' ) ) {
307
-			$value = getpaid_format_date_value( $item->get_expiration() );
305
+	public function column_renewal_date($item) {
306
+		if ($item->has_status('active trialling')) {
307
+			$value = getpaid_format_date_value($item->get_expiration());
308 308
 		} else {
309 309
 			$value = '-';
310 310
 		}
@@ -319,27 +319,27 @@  discard block
 block discarded – undo
319 319
 	 * @since       1.0.0
320 320
 	 * @return      string
321 321
 	 */
322
-	public function column_start_date( $item ) {
322
+	public function column_start_date($item) {
323 323
 
324 324
 		$gateway = $item->get_parent_invoice()->get_gateway_title();
325 325
 
326
-		if ( empty( $gateway ) ) {
327
-			return getpaid_format_date_value( $item->get_date_created() );
326
+		if (empty($gateway)) {
327
+			return getpaid_format_date_value($item->get_date_created());
328 328
 		}
329 329
 
330
-		$url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $item );
331
-		if ( ! empty( $url ) ) {
330
+		$url = apply_filters('getpaid_remote_subscription_profile_url', '', $item);
331
+		if (!empty($url)) {
332 332
 
333
-			return getpaid_format_date_value( $item->get_date_created() ) . '<br>' . sprintf(
334
-				__( 'Via %s', 'invoicing' ),
335
-				'<strong><a href="' . esc_url( $url ) . '" target="_blank">' . esc_html( $item->get_parent_invoice()->get_gateway_title() ) . '</a></strong>'
333
+			return getpaid_format_date_value($item->get_date_created()) . '<br>' . sprintf(
334
+				__('Via %s', 'invoicing'),
335
+				'<strong><a href="' . esc_url($url) . '" target="_blank">' . esc_html($item->get_parent_invoice()->get_gateway_title()) . '</a></strong>'
336 336
 			);
337 337
 
338 338
 		}
339 339
 
340
-		return getpaid_format_date_value( $item->get_date_created() ) . '<br>' . sprintf(
341
-			__( 'Via %s', 'invoicing' ),
342
-			'<strong>' . esc_html( $item->get_parent_invoice()->get_gateway_title() ) . '</strong>'
340
+		return getpaid_format_date_value($item->get_date_created()) . '<br>' . sprintf(
341
+			__('Via %s', 'invoicing'),
342
+			'<strong>' . esc_html($item->get_parent_invoice()->get_gateway_title()) . '</strong>'
343 343
 		);
344 344
 
345 345
 	}
@@ -351,8 +351,8 @@  discard block
 block discarded – undo
351 351
 	 * @since       1.0.19
352 352
 	 * @return      string
353 353
 	 */
354
-	public static function column_amount( $item ) {
355
-		$amount = getpaid_get_formatted_subscription_amount( $item );
354
+	public static function column_amount($item) {
355
+		$amount = getpaid_get_formatted_subscription_amount($item);
356 356
 		return "<span class='text-muted form-text mt-2 mb-2 ms-1 ml-1'>$amount</span>";
357 357
 	}
358 358
 
@@ -363,9 +363,9 @@  discard block
 block discarded – undo
363 363
 	 * @since       1.0.0
364 364
 	 * @return      string
365 365
 	 */
366
-	public function column_renewals( $item ) {
366
+	public function column_renewals($item) {
367 367
 		$max_bills = $item->get_bill_times();
368
-		return $item->get_times_billed() . ' / ' . ( empty( $max_bills ) ? '&infin;' : $max_bills );
368
+		return $item->get_times_billed() . ' / ' . (empty($max_bills) ? '&infin;' : $max_bills);
369 369
 	}
370 370
 
371 371
 	/**
@@ -375,15 +375,15 @@  discard block
 block discarded – undo
375 375
 	 * @since       1.0.0
376 376
 	 * @return      string
377 377
 	 */
378
-	public function column_item( $item ) {
379
-		$subscription_group = getpaid_get_invoice_subscription_group( $item->get_parent_invoice_id(), $item->get_id() );
378
+	public function column_item($item) {
379
+		$subscription_group = getpaid_get_invoice_subscription_group($item->get_parent_invoice_id(), $item->get_id());
380 380
 
381
-		if ( empty( $subscription_group ) ) {
382
-			return $this->generate_item_markup( $item->get_product_id() );
381
+		if (empty($subscription_group)) {
382
+			return $this->generate_item_markup($item->get_product_id());
383 383
 		}
384 384
 
385
-		$markup = array_map( array( $this, 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
386
-		return implode( ' | ', $markup );
385
+		$markup = array_map(array($this, 'generate_item_markup'), array_keys($subscription_group['items']));
386
+		return implode(' | ', $markup);
387 387
 
388 388
 	}
389 389
 
@@ -394,15 +394,15 @@  discard block
 block discarded – undo
394 394
 	 * @since       1.0.0
395 395
 	 * @return      string
396 396
 	 */
397
-	public static function generate_item_markup( $item_id ) {
398
-		$item = get_post( $item_id );
397
+	public static function generate_item_markup($item_id) {
398
+		$item = get_post($item_id);
399 399
 
400
-		if ( ! empty( $item ) ) {
401
-			$link = get_edit_post_link( $item );
402
-			$name = esc_html( get_the_title( $item ) );
403
-			return wpinv_current_user_can_manage_invoicing() ? "<a href='" . ( $link ? esc_url( $link ) : '#' ) . "'>$name</a>" : $name;
400
+		if (!empty($item)) {
401
+			$link = get_edit_post_link($item);
402
+			$name = esc_html(get_the_title($item));
403
+			return wpinv_current_user_can_manage_invoicing() ? "<a href='" . ($link ? esc_url($link) : '#') . "'>$name</a>" : $name;
404 404
 		} else {
405
-			return sprintf( __( 'Item #%s', 'invoicing' ), $item_id );
405
+			return sprintf(__('Item #%s', 'invoicing'), $item_id);
406 406
 		}
407 407
 
408 408
 	}
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
 	 * @return      int
414 414
 	 */
415 415
 	public function get_paged() {
416
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
416
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
417 417
 	}
418 418
 
419 419
 	/**
@@ -426,13 +426,13 @@  discard block
 block discarded – undo
426 426
 		$hidden   = array();
427 427
 		$sortable = $this->get_sortable_columns();
428 428
 
429
-		$this->_column_headers = array( $columns, $hidden, $sortable );
429
+		$this->_column_headers = array($columns, $hidden, $sortable);
430 430
 
431 431
 		$this->set_pagination_args(
432 432
 			array(
433 433
 				'total_items' => $this->current_total_count,
434 434
 				'per_page'    => $this->per_page,
435
-				'total_pages' => ceil( $this->current_total_count / $this->per_page ),
435
+				'total_pages' => ceil($this->current_total_count / $this->per_page),
436 436
 			)
437 437
 		);
438 438
 	}
@@ -445,15 +445,15 @@  discard block
 block discarded – undo
445 445
 	public function get_columns() {
446 446
 		$columns = array(
447 447
 			'cb'           => '<input type="checkbox" />',
448
-			'subscription' => __( 'Subscription', 'invoicing' ),
449
-			'start_date'   => __( 'Start Date', 'invoicing' ),
450
-			'renewal_date' => __( 'Next Payment', 'invoicing' ),
451
-			'renewals'     => __( 'Payments', 'invoicing' ),
452
-			'item'         => __( 'Items', 'invoicing' ),
453
-			'status'       => __( 'Status', 'invoicing' ),
448
+			'subscription' => __('Subscription', 'invoicing'),
449
+			'start_date'   => __('Start Date', 'invoicing'),
450
+			'renewal_date' => __('Next Payment', 'invoicing'),
451
+			'renewals'     => __('Payments', 'invoicing'),
452
+			'item'         => __('Items', 'invoicing'),
453
+			'status'       => __('Status', 'invoicing'),
454 454
 		);
455 455
 
456
-		return apply_filters( 'manage_getpaid_subscriptions_table_columns', $columns );
456
+		return apply_filters('manage_getpaid_subscriptions_table_columns', $columns);
457 457
 	}
458 458
 
459 459
 	/**
@@ -463,15 +463,15 @@  discard block
 block discarded – undo
463 463
 	 */
464 464
 	public function get_sortable_columns() {
465 465
 		$sortable = array(
466
-			'subscription' => array( 'id', true ),
467
-			'start_date'   => array( 'created', true ),
468
-			'renewal_date' => array( 'expiration', true ),
469
-			'renewals'     => array( 'bill_times', true ),
470
-			'item'         => array( 'product_id', true ),
471
-			'status'       => array( 'status', true ),
466
+			'subscription' => array('id', true),
467
+			'start_date'   => array('created', true),
468
+			'renewal_date' => array('expiration', true),
469
+			'renewals'     => array('bill_times', true),
470
+			'item'         => array('product_id', true),
471
+			'status'       => array('status', true),
472 472
 		);
473 473
 
474
-		return apply_filters( 'manage_getpaid_subscriptions_sortable_table_columns', $sortable );
474
+		return apply_filters('manage_getpaid_subscriptions_sortable_table_columns', $sortable);
475 475
 	}
476 476
 
477 477
 	/**
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 	 * @return bool
481 481
 	 */
482 482
 	public function has_items() {
483
-		return ! empty( $this->current_total_count );
483
+		return !empty($this->current_total_count);
484 484
 	}
485 485
 
486 486
 	/**
Please login to merge, or discard this patch.