Passed
Push — master ( a15c21...706a80 )
by Stiofan
04:34
created
vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -7,40 +7,40 @@
 block discarded – undo
7 7
  * Bail if we are not in WP.
8 8
  */
9 9
 if ( ! defined( 'ABSPATH' ) ) {
10
-	exit;
10
+    exit;
11 11
 }
12 12
 
13 13
 /**
14 14
  * Set the version only if its the current newest while loading.
15 15
  */
16 16
 add_action('after_setup_theme', function () {
17
-	global $ayecode_ui_version,$ayecode_ui_file_key;
18
-	$this_version = "0.1.51";
19
-	if(version_compare($this_version , $ayecode_ui_version, '>')){
20
-		$ayecode_ui_version = $this_version ;
21
-		$ayecode_ui_file_key = wp_hash( __FILE__ );
22
-	}
17
+    global $ayecode_ui_version,$ayecode_ui_file_key;
18
+    $this_version = "0.1.51";
19
+    if(version_compare($this_version , $ayecode_ui_version, '>')){
20
+        $ayecode_ui_version = $this_version ;
21
+        $ayecode_ui_file_key = wp_hash( __FILE__ );
22
+    }
23 23
 },0);
24 24
 
25 25
 /**
26 26
  * Load this version of WP Bootstrap Settings only if the file hash is the current one.
27 27
  */
28 28
 add_action('after_setup_theme', function () {
29
-	global $ayecode_ui_file_key;
30
-	if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
-		include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
-		include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
33
-	}
29
+    global $ayecode_ui_file_key;
30
+    if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
+        include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
+        include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
33
+    }
34 34
 },1);
35 35
 
36 36
 /**
37 37
  * Add the function that calls the class.
38 38
  */
39 39
 if(!function_exists('aui')){
40
-	function aui(){
41
-		if(!class_exists("AUI",false)){
42
-			return false;
43
-		}
44
-		return AUI::instance();
45
-	}
40
+    function aui(){
41
+        if(!class_exists("AUI",false)){
42
+            return false;
43
+        }
44
+        return AUI::instance();
45
+    }
46 46
 }
47 47
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -6,39 +6,39 @@
 block discarded – undo
6 6
 /**
7 7
  * Bail if we are not in WP.
8 8
  */
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if (!defined('ABSPATH')) {
10 10
 	exit;
11 11
 }
12 12
 
13 13
 /**
14 14
  * Set the version only if its the current newest while loading.
15 15
  */
16
-add_action('after_setup_theme', function () {
17
-	global $ayecode_ui_version,$ayecode_ui_file_key;
16
+add_action('after_setup_theme', function() {
17
+	global $ayecode_ui_version, $ayecode_ui_file_key;
18 18
 	$this_version = "0.1.51";
19
-	if(version_compare($this_version , $ayecode_ui_version, '>')){
20
-		$ayecode_ui_version = $this_version ;
21
-		$ayecode_ui_file_key = wp_hash( __FILE__ );
19
+	if (version_compare($this_version, $ayecode_ui_version, '>')) {
20
+		$ayecode_ui_version = $this_version;
21
+		$ayecode_ui_file_key = wp_hash(__FILE__);
22 22
 	}
23 23
 },0);
24 24
 
25 25
 /**
26 26
  * Load this version of WP Bootstrap Settings only if the file hash is the current one.
27 27
  */
28
-add_action('after_setup_theme', function () {
28
+add_action('after_setup_theme', function() {
29 29
 	global $ayecode_ui_file_key;
30
-	if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
-		include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
-		include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
30
+	if ($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash(__FILE__)) {
31
+		include_once(dirname(__FILE__) . '/includes/class-aui.php');
32
+		include_once(dirname(__FILE__) . '/includes/ayecode-ui-settings.php');
33 33
 	}
34 34
 },1);
35 35
 
36 36
 /**
37 37
  * Add the function that calls the class.
38 38
  */
39
-if(!function_exists('aui')){
40
-	function aui(){
41
-		if(!class_exists("AUI",false)){
39
+if (!function_exists('aui')) {
40
+	function aui() {
41
+		if (!class_exists("AUI", false)) {
42 42
 			return false;
43 43
 		}
44 44
 		return AUI::instance();
Please login to merge, or discard this patch.
includes/wpinv-subscription.php 2 patches
Indentation   +1035 added lines, -1035 removed lines patch added patch discarded remove patch
@@ -15,125 +15,125 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class WPInv_Subscription extends GetPaid_Data {
17 17
 
18
-	/**
19
-	 * Which data store to load.
20
-	 *
21
-	 * @var string
22
-	 */
23
-	protected $data_store_name = 'subscription';
24
-
25
-	/**
26
-	 * This is the name of this object type.
27
-	 *
28
-	 * @var string
29
-	 */
30
-	protected $object_type = 'subscription';
31
-
32
-	/**
33
-	 * Item Data array. This is the core item data exposed in APIs.
34
-	 *
35
-	 * @since 1.0.19
36
-	 * @var array
37
-	 */
38
-	protected $data = array(
39
-		'customer_id'       => 0,
40
-		'frequency'         => 1,
41
-		'period'            => 'D',
42
-		'initial_amount'    => null,
43
-		'recurring_amount'  => null,
44
-		'bill_times'        => 0,
45
-		'transaction_id'    => '',
46
-		'parent_payment_id' => null,
47
-		'product_id'        => 0,
48
-		'created'           => '0000-00-00 00:00:00',
49
-		'expiration'        => '0000-00-00 00:00:00',
50
-		'trial_period'      => '',
51
-		'status'            => 'pending',
52
-		'profile_id'        => '',
53
-		'gateway'           => '',
54
-		'customer'          => '',
55
-	);
56
-
57
-	/**
58
-	 * Stores the status transition information.
59
-	 *
60
-	 * @since 1.0.19
61
-	 * @var bool
62
-	 */
63
-	protected $status_transition = false;
64
-
65
-	/**
66
-	 * Get the subscription if ID is passed, otherwise the subscription is new and empty.
67
-	 *
68
-	 * @param  int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read.
69
-	 * @param  bool $deprecated
70
-	 */
71
-	function __construct( $subscription = 0, $deprecated = false ) {
72
-
73
-		parent::__construct( $subscription );
74
-
75
-		if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) {
76
-			$this->set_id( $subscription );
77
-		} elseif ( $subscription instanceof self ) {
78
-			$this->set_id( $subscription->get_id() );
79
-		} elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) {
80
-			$this->set_id( $subscription_id );
81
-		} elseif ( ! empty( $subscription->id ) ) {
82
-			$this->set_id( $subscription->id );
83
-		} else {
84
-			$this->set_object_read( true );
85
-		}
86
-
87
-		// Load the datastore.
88
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
89
-
90
-		if ( $this->get_id() > 0 ) {
91
-			$this->data_store->read( $this );
92
-		}
93
-
94
-	}
95
-
96
-	/**
97
-	 * Given an invoice id, profile id, transaction id, it returns the subscription's id.
98
-	 *
99
-	 *
100
-	 * @static
101
-	 * @param string $value
102
-	 * @param string $field Either invoice_id, transaction_id or profile_id.
103
-	 * @since 1.0.19
104
-	 * @return int
105
-	 */
106
-	public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) {
18
+    /**
19
+     * Which data store to load.
20
+     *
21
+     * @var string
22
+     */
23
+    protected $data_store_name = 'subscription';
24
+
25
+    /**
26
+     * This is the name of this object type.
27
+     *
28
+     * @var string
29
+     */
30
+    protected $object_type = 'subscription';
31
+
32
+    /**
33
+     * Item Data array. This is the core item data exposed in APIs.
34
+     *
35
+     * @since 1.0.19
36
+     * @var array
37
+     */
38
+    protected $data = array(
39
+        'customer_id'       => 0,
40
+        'frequency'         => 1,
41
+        'period'            => 'D',
42
+        'initial_amount'    => null,
43
+        'recurring_amount'  => null,
44
+        'bill_times'        => 0,
45
+        'transaction_id'    => '',
46
+        'parent_payment_id' => null,
47
+        'product_id'        => 0,
48
+        'created'           => '0000-00-00 00:00:00',
49
+        'expiration'        => '0000-00-00 00:00:00',
50
+        'trial_period'      => '',
51
+        'status'            => 'pending',
52
+        'profile_id'        => '',
53
+        'gateway'           => '',
54
+        'customer'          => '',
55
+    );
56
+
57
+    /**
58
+     * Stores the status transition information.
59
+     *
60
+     * @since 1.0.19
61
+     * @var bool
62
+     */
63
+    protected $status_transition = false;
64
+
65
+    /**
66
+     * Get the subscription if ID is passed, otherwise the subscription is new and empty.
67
+     *
68
+     * @param  int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read.
69
+     * @param  bool $deprecated
70
+     */
71
+    function __construct( $subscription = 0, $deprecated = false ) {
72
+
73
+        parent::__construct( $subscription );
74
+
75
+        if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) {
76
+            $this->set_id( $subscription );
77
+        } elseif ( $subscription instanceof self ) {
78
+            $this->set_id( $subscription->get_id() );
79
+        } elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) {
80
+            $this->set_id( $subscription_id );
81
+        } elseif ( ! empty( $subscription->id ) ) {
82
+            $this->set_id( $subscription->id );
83
+        } else {
84
+            $this->set_object_read( true );
85
+        }
86
+
87
+        // Load the datastore.
88
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
89
+
90
+        if ( $this->get_id() > 0 ) {
91
+            $this->data_store->read( $this );
92
+        }
93
+
94
+    }
95
+
96
+    /**
97
+     * Given an invoice id, profile id, transaction id, it returns the subscription's id.
98
+     *
99
+     *
100
+     * @static
101
+     * @param string $value
102
+     * @param string $field Either invoice_id, transaction_id or profile_id.
103
+     * @since 1.0.19
104
+     * @return int
105
+     */
106
+    public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) {
107 107
         global $wpdb;
108 108
 
109
-		// Trim the value.
110
-		$value = trim( $value );
109
+        // Trim the value.
110
+        $value = trim( $value );
111 111
 
112
-		if ( empty( $value ) ) {
113
-			return 0;
114
-		}
112
+        if ( empty( $value ) ) {
113
+            return 0;
114
+        }
115 115
 
116
-		if ( 'invoice_id' == $field ) {
117
-			$field = 'parent_payment_id';
118
-		}
116
+        if ( 'invoice_id' == $field ) {
117
+            $field = 'parent_payment_id';
118
+        }
119 119
 
120 120
         // Valid fields.
121 121
         $fields = array(
122
-			'parent_payment_id',
123
-			'transaction_id',
124
-			'profile_id'
125
-		);
126
-
127
-		// Ensure a field has been passed.
128
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
129
-			return 0;
130
-		}
131
-
132
-		// Maybe retrieve from the cache.
133
-		$subscription_id   = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" );
134
-		if ( ! empty( $subscription_id ) ) {
135
-			return $subscription_id;
136
-		}
122
+            'parent_payment_id',
123
+            'transaction_id',
124
+            'profile_id'
125
+        );
126
+
127
+        // Ensure a field has been passed.
128
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
129
+            return 0;
130
+        }
131
+
132
+        // Maybe retrieve from the cache.
133
+        $subscription_id   = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" );
134
+        if ( ! empty( $subscription_id ) ) {
135
+            return $subscription_id;
136
+        }
137 137
 
138 138
         // Fetch from the db.
139 139
         $table            = $wpdb->prefix . 'wpinv_subscriptions';
@@ -141,34 +141,34 @@  discard block
 block discarded – undo
141 141
             $wpdb->prepare( "SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
142 142
         );
143 143
 
144
-		if ( empty( $subscription_id ) ) {
145
-			return 0;
146
-		}
144
+        if ( empty( $subscription_id ) ) {
145
+            return 0;
146
+        }
147 147
 
148
-		// Update the cache with our data.
149
-		wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" );
148
+        // Update the cache with our data.
149
+        wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" );
150 150
 
151
-		return $subscription_id;
152
-	}
151
+        return $subscription_id;
152
+    }
153 153
 
154
-	/**
154
+    /**
155 155
      * Clears the subscription's cache.
156 156
      */
157 157
     public function clear_cache() {
158
-		wp_cache_delete( $this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids' );
159
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids' );
160
-		wp_cache_delete( $this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids' );
161
-		wp_cache_delete( $this->get_id(), 'getpaid_subscriptions' );
162
-	}
158
+        wp_cache_delete( $this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids' );
159
+        wp_cache_delete( $this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids' );
160
+        wp_cache_delete( $this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids' );
161
+        wp_cache_delete( $this->get_id(), 'getpaid_subscriptions' );
162
+    }
163 163
 
164
-	/**
164
+    /**
165 165
      * Checks if a subscription key is set.
166 166
      */
167 167
     public function _isset( $key ) {
168 168
         return isset( $this->data[$key] ) || method_exists( $this, "get_$key" );
169
-	}
169
+    }
170 170
 
171
-	/*
171
+    /*
172 172
 	|--------------------------------------------------------------------------
173 173
 	| CRUD methods
174 174
 	|--------------------------------------------------------------------------
@@ -177,545 +177,545 @@  discard block
 block discarded – undo
177 177
 	|
178 178
     */
179 179
 
180
-	/*
181
-	|--------------------------------------------------------------------------
182
-	| Getters
183
-	|--------------------------------------------------------------------------
184
-	*/
180
+    /*
181
+	|--------------------------------------------------------------------------
182
+	| Getters
183
+	|--------------------------------------------------------------------------
184
+	*/
185
+
186
+    /**
187
+     * Get customer id.
188
+     *
189
+     * @since 1.0.19
190
+     * @param  string $context View or edit context.
191
+     * @return int
192
+     */
193
+    public function get_customer_id( $context = 'view' ) {
194
+        return (int) $this->get_prop( 'customer_id', $context );
195
+    }
196
+
197
+    /**
198
+     * Get customer information.
199
+     *
200
+     * @since 1.0.19
201
+     * @param  string $context View or edit context.
202
+     * @return WP_User|false WP_User object on success, false on failure.
203
+     */
204
+    public function get_customer( $context = 'view' ) {
205
+        return get_userdata( $this->get_customer_id( $context ) );
206
+    }
207
+
208
+    /**
209
+     * Get parent invoice id.
210
+     *
211
+     * @since 1.0.19
212
+     * @param  string $context View or edit context.
213
+     * @return int
214
+     */
215
+    public function get_parent_invoice_id( $context = 'view' ) {
216
+        return (int) $this->get_prop( 'parent_payment_id', $context );
217
+    }
218
+
219
+    /**
220
+     * Alias for self::get_parent_invoice_id().
221
+     *
222
+     * @since 1.0.19
223
+     * @param  string $context View or edit context.
224
+     * @return int
225
+     */
226
+    public function get_parent_payment_id( $context = 'view' ) {
227
+        return $this->get_parent_invoice_id( $context );
228
+    }
229
+
230
+    /**
231
+     * Alias for self::get_parent_invoice_id().
232
+     *
233
+     * @since  1.0.0
234
+     * @return int
235
+     */
236
+    public function get_original_payment_id( $context = 'view' ) {
237
+        return $this->get_parent_invoice_id( $context );
238
+    }
239
+
240
+    /**
241
+     * Get parent invoice.
242
+     *
243
+     * @since 1.0.19
244
+     * @param  string $context View or edit context.
245
+     * @return WPInv_Invoice
246
+     */
247
+    public function get_parent_invoice( $context = 'view' ) {
248
+        return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) );
249
+    }
250
+
251
+    /**
252
+     * Alias for self::get_parent_invoice().
253
+     *
254
+     * @since 1.0.19
255
+     * @param  string $context View or edit context.
256
+     * @return WPInv_Invoice
257
+     */
258
+    public function get_parent_payment( $context = 'view' ) {
259
+        return $this->get_parent_invoice( $context );
260
+    }
261
+
262
+    /**
263
+     * Get subscription's product id.
264
+     *
265
+     * @since 1.0.19
266
+     * @param  string $context View or edit context.
267
+     * @return int
268
+     */
269
+    public function get_product_id( $context = 'view' ) {
270
+        return (int) $this->get_prop( 'product_id', $context );
271
+    }
272
+
273
+    /**
274
+     * Get the subscription product.
275
+     *
276
+     * @since 1.0.19
277
+     * @param  string $context View or edit context.
278
+     * @return WPInv_Item
279
+     */
280
+    public function get_product( $context = 'view' ) {
281
+        return new WPInv_Item( $this->get_product_id( $context ) );
282
+    }
283
+
284
+    /**
285
+     * Get parent invoice's gateway.
286
+     *
287
+     * Here for backwards compatibility.
288
+     *
289
+     * @since 1.0.19
290
+     * @param  string $context View or edit context.
291
+     * @return string
292
+     */
293
+    public function get_gateway( $context = 'view' ) {
294
+        return $this->get_parent_invoice( $context )->get_gateway();
295
+    }
296
+
297
+    /**
298
+     * Get the period of a renewal.
299
+     *
300
+     * @since 1.0.19
301
+     * @param  string $context View or edit context.
302
+     * @return string
303
+     */
304
+    public function get_period( $context = 'view' ) {
305
+        return $this->get_prop( 'period', $context );
306
+    }
307
+
308
+    /**
309
+     * Get number of periods each renewal is valid for.
310
+     *
311
+     * @since 1.0.19
312
+     * @param  string $context View or edit context.
313
+     * @return int
314
+     */
315
+    public function get_frequency( $context = 'view' ) {
316
+        return (int) $this->get_prop( 'frequency', $context );
317
+    }
318
+
319
+    /**
320
+     * Get the initial amount for the subscription.
321
+     *
322
+     * @since 1.0.19
323
+     * @param  string $context View or edit context.
324
+     * @return float
325
+     */
326
+    public function get_initial_amount( $context = 'view' ) {
327
+        return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) );
328
+    }
329
+
330
+    /**
331
+     * Get the recurring amount for the subscription.
332
+     *
333
+     * @since 1.0.19
334
+     * @param  string $context View or edit context.
335
+     * @return float
336
+     */
337
+    public function get_recurring_amount( $context = 'view' ) {
338
+        return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) );
339
+    }
340
+
341
+    /**
342
+     * Get number of times that this subscription can be renewed.
343
+     *
344
+     * @since 1.0.19
345
+     * @param  string $context View or edit context.
346
+     * @return int
347
+     */
348
+    public function get_bill_times( $context = 'view' ) {
349
+        return (int) $this->get_prop( 'bill_times', $context );
350
+    }
351
+
352
+    /**
353
+     * Get transaction id of this subscription's parent invoice.
354
+     *
355
+     * @since 1.0.19
356
+     * @param  string $context View or edit context.
357
+     * @return string
358
+     */
359
+    public function get_transaction_id( $context = 'view' ) {
360
+        return $this->get_prop( 'transaction_id', $context );
361
+    }
362
+
363
+    /**
364
+     * Get the date that the subscription was created.
365
+     *
366
+     * @since 1.0.19
367
+     * @param  string $context View or edit context.
368
+     * @return string
369
+     */
370
+    public function get_created( $context = 'view' ) {
371
+        return $this->get_prop( 'created', $context );
372
+    }
373
+
374
+    /**
375
+     * Alias for self::get_created().
376
+     *
377
+     * @since 1.0.19
378
+     * @param  string $context View or edit context.
379
+     * @return string
380
+     */
381
+    public function get_date_created( $context = 'view' ) {
382
+        return $this->get_created( $context );
383
+    }
384
+
385
+    /**
386
+     * Retrieves the creation date in a timestamp
387
+     *
388
+     * @since  1.0.0
389
+     * @return int
390
+     */
391
+    public function get_time_created() {
392
+        $created = $this->get_date_created();
393
+        return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) );
394
+    }
395
+
396
+    /**
397
+     * Get GMT date when the subscription was created.
398
+     *
399
+     * @since 1.0.19
400
+     * @param  string $context View or edit context.
401
+     * @return string
402
+     */
403
+    public function get_date_created_gmt( $context = 'view' ) {
404
+        $date = $this->get_date_created( $context );
405
+
406
+        if ( $date ) {
407
+            $date = get_gmt_from_date( $date );
408
+        }
409
+        return $date;
410
+    }
411
+
412
+    /**
413
+     * Get the date that the subscription will renew.
414
+     *
415
+     * @since 1.0.19
416
+     * @param  string $context View or edit context.
417
+     * @return string
418
+     */
419
+    public function get_next_renewal_date( $context = 'view' ) {
420
+        return $this->get_prop( 'expiration', $context );
421
+    }
422
+
423
+    /**
424
+     * Alias for self::get_next_renewal_date().
425
+     *
426
+     * @since 1.0.19
427
+     * @param  string $context View or edit context.
428
+     * @return string
429
+     */
430
+    public function get_expiration( $context = 'view' ) {
431
+        return $this->get_next_renewal_date( $context );
432
+    }
433
+
434
+    /**
435
+     * Retrieves the expiration date in a timestamp
436
+     *
437
+     * @since  1.0.0
438
+     * @return int
439
+     */
440
+    public function get_expiration_time() {
441
+        $expiration = $this->get_expiration();
442
+
443
+        if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
444
+            return current_time( 'timestamp' );
445
+        }
446
+
447
+        $expiration = strtotime( $expiration, current_time( 'timestamp' ) );
448
+        return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration;
449
+    }
450
+
451
+    /**
452
+     * Get GMT date when the subscription will renew.
453
+     *
454
+     * @since 1.0.19
455
+     * @param  string $context View or edit context.
456
+     * @return string
457
+     */
458
+    public function get_next_renewal_date_gmt( $context = 'view' ) {
459
+        $date = $this->get_next_renewal_date( $context );
460
+
461
+        if ( $date ) {
462
+            $date = get_gmt_from_date( $date );
463
+        }
464
+        return $date;
465
+    }
466
+
467
+    /**
468
+     * Get the subscription's trial period.
469
+     *
470
+     * @since 1.0.19
471
+     * @param  string $context View or edit context.
472
+     * @return string
473
+     */
474
+    public function get_trial_period( $context = 'view' ) {
475
+        return $this->get_prop( 'trial_period', $context );
476
+    }
477
+
478
+    /**
479
+     * Get the subscription's status.
480
+     *
481
+     * @since 1.0.19
482
+     * @param  string $context View or edit context.
483
+     * @return string
484
+     */
485
+    public function get_status( $context = 'view' ) {
486
+        return $this->get_prop( 'status', $context );
487
+    }
488
+
489
+    /**
490
+     * Get the subscription's profile id.
491
+     *
492
+     * @since 1.0.19
493
+     * @param  string $context View or edit context.
494
+     * @return string
495
+     */
496
+    public function get_profile_id( $context = 'view' ) {
497
+        return $this->get_prop( 'profile_id', $context );
498
+    }
499
+
500
+    /*
501
+	|--------------------------------------------------------------------------
502
+	| Setters
503
+	|--------------------------------------------------------------------------
504
+	*/
505
+
506
+    /**
507
+     * Set customer id.
508
+     *
509
+     * @since 1.0.19
510
+     * @param  int $value The customer's id.
511
+     */
512
+    public function set_customer_id( $value ) {
513
+        $this->set_prop( 'customer_id', (int) $value );
514
+    }
515
+
516
+    /**
517
+     * Set parent invoice id.
518
+     *
519
+     * @since 1.0.19
520
+     * @param  int $value The parent invoice id.
521
+     */
522
+    public function set_parent_invoice_id( $value ) {
523
+        $this->set_prop( 'parent_payment_id', (int) $value );
524
+    }
525
+
526
+    /**
527
+     * Alias for self::set_parent_invoice_id().
528
+     *
529
+     * @since 1.0.19
530
+     * @param  int $value The parent invoice id.
531
+     */
532
+    public function set_parent_payment_id( $value ) {
533
+        $this->set_parent_invoice_id( $value );
534
+    }
535
+
536
+    /**
537
+     * Alias for self::set_parent_invoice_id().
538
+     *
539
+     * @since 1.0.19
540
+     * @param  int $value The parent invoice id.
541
+     */
542
+    public function set_original_payment_id( $value ) {
543
+        $this->set_parent_invoice_id( $value );
544
+    }
545
+
546
+    /**
547
+     * Set subscription's product id.
548
+     *
549
+     * @since 1.0.19
550
+     * @param  int $value The subscription product id.
551
+     */
552
+    public function set_product_id( $value ) {
553
+        $this->set_prop( 'product_id', (int) $value );
554
+    }
555
+
556
+    /**
557
+     * Set the period of a renewal.
558
+     *
559
+     * @since 1.0.19
560
+     * @param  string $value The renewal period.
561
+     */
562
+    public function set_period( $value ) {
563
+        $this->set_prop( 'period', $value );
564
+    }
565
+
566
+    /**
567
+     * Set number of periods each renewal is valid for.
568
+     *
569
+     * @since 1.0.19
570
+     * @param  int $value The subscription frequency.
571
+     */
572
+    public function set_frequency( $value ) {
573
+        $value = empty( $value ) ? 1 : (int) $value;
574
+        $this->set_prop( 'frequency', absint( $value ) );
575
+    }
576
+
577
+    /**
578
+     * Set the initial amount for the subscription.
579
+     *
580
+     * @since 1.0.19
581
+     * @param  float $value The initial subcription amount.
582
+     */
583
+    public function set_initial_amount( $value ) {
584
+        $this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) );
585
+    }
586
+
587
+    /**
588
+     * Set the recurring amount for the subscription.
589
+     *
590
+     * @since 1.0.19
591
+     * @param  float $value The recurring subcription amount.
592
+     */
593
+    public function set_recurring_amount( $value ) {
594
+        $this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) );
595
+    }
596
+
597
+    /**
598
+     * Set number of times that this subscription can be renewed.
599
+     *
600
+     * @since 1.0.19
601
+     * @param  int $value Bill times.
602
+     */
603
+    public function set_bill_times( $value ) {
604
+        $this->set_prop( 'bill_times', (int) $value );
605
+    }
606
+
607
+    /**
608
+     * Get transaction id of this subscription's parent invoice.
609
+     *
610
+     * @since 1.0.19
611
+     * @param string $value Bill times.
612
+     */
613
+    public function set_transaction_id( $value ) {
614
+        $this->set_prop( 'transaction_id', sanitize_text_field( $value ) );
615
+    }
616
+
617
+    /**
618
+     * Set date when this subscription started.
619
+     *
620
+     * @since 1.0.19
621
+     * @param string $value strtotime compliant date.
622
+     */
623
+    public function set_created( $value ) {
624
+        $date = strtotime( $value );
625
+
626
+        if ( $date && $value !== '0000-00-00 00:00:00' ) {
627
+            $this->set_prop( 'created', date( 'Y-m-d H:i:s', $date ) );
628
+            return;
629
+        }
630
+
631
+        $this->set_prop( 'created', '' );
185 632
 
186
-	/**
187
-	 * Get customer id.
188
-	 *
189
-	 * @since 1.0.19
190
-	 * @param  string $context View or edit context.
191
-	 * @return int
192
-	 */
193
-	public function get_customer_id( $context = 'view' ) {
194
-		return (int) $this->get_prop( 'customer_id', $context );
195
-	}
196
-
197
-	/**
198
-	 * Get customer information.
199
-	 *
200
-	 * @since 1.0.19
201
-	 * @param  string $context View or edit context.
202
-	 * @return WP_User|false WP_User object on success, false on failure.
203
-	 */
204
-	public function get_customer( $context = 'view' ) {
205
-		return get_userdata( $this->get_customer_id( $context ) );
206
-	}
207
-
208
-	/**
209
-	 * Get parent invoice id.
210
-	 *
211
-	 * @since 1.0.19
212
-	 * @param  string $context View or edit context.
213
-	 * @return int
214
-	 */
215
-	public function get_parent_invoice_id( $context = 'view' ) {
216
-		return (int) $this->get_prop( 'parent_payment_id', $context );
217
-	}
218
-
219
-	/**
220
-	 * Alias for self::get_parent_invoice_id().
221
-	 *
222
-	 * @since 1.0.19
223
-	 * @param  string $context View or edit context.
224
-	 * @return int
225
-	 */
226
-    public function get_parent_payment_id( $context = 'view' ) {
227
-        return $this->get_parent_invoice_id( $context );
228
-	}
633
+    }
229 634
 
230
-	/**
231
-     * Alias for self::get_parent_invoice_id().
635
+    /**
636
+     * Alias for self::set_created().
232 637
      *
233
-     * @since  1.0.0
234
-     * @return int
638
+     * @since 1.0.19
639
+     * @param string $value strtotime compliant date.
235 640
      */
236
-    public function get_original_payment_id( $context = 'view' ) {
237
-        return $this->get_parent_invoice_id( $context );
641
+    public function set_date_created( $value ) {
642
+        $this->set_created( $value );
238 643
     }
239 644
 
240
-	/**
241
-	 * Get parent invoice.
242
-	 *
243
-	 * @since 1.0.19
244
-	 * @param  string $context View or edit context.
245
-	 * @return WPInv_Invoice
246
-	 */
247
-	public function get_parent_invoice( $context = 'view' ) {
248
-		return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) );
249
-	}
250
-
251
-	/**
252
-	 * Alias for self::get_parent_invoice().
253
-	 *
254
-	 * @since 1.0.19
255
-	 * @param  string $context View or edit context.
256
-	 * @return WPInv_Invoice
257
-	 */
258
-    public function get_parent_payment( $context = 'view' ) {
259
-        return $this->get_parent_invoice( $context );
260
-	}
261
-
262
-	/**
263
-	 * Get subscription's product id.
264
-	 *
265
-	 * @since 1.0.19
266
-	 * @param  string $context View or edit context.
267
-	 * @return int
268
-	 */
269
-	public function get_product_id( $context = 'view' ) {
270
-		return (int) $this->get_prop( 'product_id', $context );
271
-	}
272
-
273
-	/**
274
-	 * Get the subscription product.
275
-	 *
276
-	 * @since 1.0.19
277
-	 * @param  string $context View or edit context.
278
-	 * @return WPInv_Item
279
-	 */
280
-	public function get_product( $context = 'view' ) {
281
-		return new WPInv_Item( $this->get_product_id( $context ) );
282
-	}
283
-
284
-	/**
285
-	 * Get parent invoice's gateway.
286
-	 *
287
-	 * Here for backwards compatibility.
288
-	 *
289
-	 * @since 1.0.19
290
-	 * @param  string $context View or edit context.
291
-	 * @return string
292
-	 */
293
-	public function get_gateway( $context = 'view' ) {
294
-		return $this->get_parent_invoice( $context )->get_gateway();
295
-	}
296
-
297
-	/**
298
-	 * Get the period of a renewal.
299
-	 *
300
-	 * @since 1.0.19
301
-	 * @param  string $context View or edit context.
302
-	 * @return string
303
-	 */
304
-	public function get_period( $context = 'view' ) {
305
-		return $this->get_prop( 'period', $context );
306
-	}
307
-
308
-	/**
309
-	 * Get number of periods each renewal is valid for.
310
-	 *
311
-	 * @since 1.0.19
312
-	 * @param  string $context View or edit context.
313
-	 * @return int
314
-	 */
315
-	public function get_frequency( $context = 'view' ) {
316
-		return (int) $this->get_prop( 'frequency', $context );
317
-	}
318
-
319
-	/**
320
-	 * Get the initial amount for the subscription.
321
-	 *
322
-	 * @since 1.0.19
323
-	 * @param  string $context View or edit context.
324
-	 * @return float
325
-	 */
326
-	public function get_initial_amount( $context = 'view' ) {
327
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) );
328
-	}
329
-
330
-	/**
331
-	 * Get the recurring amount for the subscription.
332
-	 *
333
-	 * @since 1.0.19
334
-	 * @param  string $context View or edit context.
335
-	 * @return float
336
-	 */
337
-	public function get_recurring_amount( $context = 'view' ) {
338
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) );
339
-	}
340
-
341
-	/**
342
-	 * Get number of times that this subscription can be renewed.
343
-	 *
344
-	 * @since 1.0.19
345
-	 * @param  string $context View or edit context.
346
-	 * @return int
347
-	 */
348
-	public function get_bill_times( $context = 'view' ) {
349
-		return (int) $this->get_prop( 'bill_times', $context );
350
-	}
351
-
352
-	/**
353
-	 * Get transaction id of this subscription's parent invoice.
354
-	 *
355
-	 * @since 1.0.19
356
-	 * @param  string $context View or edit context.
357
-	 * @return string
358
-	 */
359
-	public function get_transaction_id( $context = 'view' ) {
360
-		return $this->get_prop( 'transaction_id', $context );
361
-	}
362
-
363
-	/**
364
-	 * Get the date that the subscription was created.
365
-	 *
366
-	 * @since 1.0.19
367
-	 * @param  string $context View or edit context.
368
-	 * @return string
369
-	 */
370
-	public function get_created( $context = 'view' ) {
371
-		return $this->get_prop( 'created', $context );
372
-	}
373
-
374
-	/**
375
-	 * Alias for self::get_created().
376
-	 *
377
-	 * @since 1.0.19
378
-	 * @param  string $context View or edit context.
379
-	 * @return string
380
-	 */
381
-	public function get_date_created( $context = 'view' ) {
382
-		return $this->get_created( $context );
383
-	}
384
-
385
-	/**
386
-	 * Retrieves the creation date in a timestamp
387
-	 *
388
-	 * @since  1.0.0
389
-	 * @return int
390
-	 */
391
-	public function get_time_created() {
392
-		$created = $this->get_date_created();
393
-		return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) );
394
-	}
395
-
396
-	/**
397
-	 * Get GMT date when the subscription was created.
398
-	 *
399
-	 * @since 1.0.19
400
-	 * @param  string $context View or edit context.
401
-	 * @return string
402
-	 */
403
-	public function get_date_created_gmt( $context = 'view' ) {
404
-        $date = $this->get_date_created( $context );
645
+    /**
646
+     * Set the date that the subscription will renew.
647
+     *
648
+     * @since 1.0.19
649
+     * @param string $value strtotime compliant date.
650
+     */
651
+    public function set_next_renewal_date( $value ) {
652
+        $date = strtotime( $value );
405 653
 
406
-        if ( $date ) {
407
-            $date = get_gmt_from_date( $date );
654
+        if ( $date && $value !== '0000-00-00 00:00:00' ) {
655
+            $this->set_prop( 'expiration', date( 'Y-m-d H:i:s', $date ) );
656
+            return;
408 657
         }
409
-		return $date;
410
-	}
411
-
412
-	/**
413
-	 * Get the date that the subscription will renew.
414
-	 *
415
-	 * @since 1.0.19
416
-	 * @param  string $context View or edit context.
417
-	 * @return string
418
-	 */
419
-	public function get_next_renewal_date( $context = 'view' ) {
420
-		return $this->get_prop( 'expiration', $context );
421
-	}
422
-
423
-	/**
424
-	 * Alias for self::get_next_renewal_date().
425
-	 *
426
-	 * @since 1.0.19
427
-	 * @param  string $context View or edit context.
428
-	 * @return string
429
-	 */
430
-	public function get_expiration( $context = 'view' ) {
431
-		return $this->get_next_renewal_date( $context );
432
-	}
433
-
434
-	/**
435
-	 * Retrieves the expiration date in a timestamp
436
-	 *
437
-	 * @since  1.0.0
438
-	 * @return int
439
-	 */
440
-	public function get_expiration_time() {
441
-		$expiration = $this->get_expiration();
442
-
443
-		if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
444
-			return current_time( 'timestamp' );
445
-		}
446
-
447
-		$expiration = strtotime( $expiration, current_time( 'timestamp' ) );
448
-		return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration;
449
-	}
450
-
451
-	/**
452
-	 * Get GMT date when the subscription will renew.
453
-	 *
454
-	 * @since 1.0.19
455
-	 * @param  string $context View or edit context.
456
-	 * @return string
457
-	 */
458
-	public function get_next_renewal_date_gmt( $context = 'view' ) {
459
-        $date = $this->get_next_renewal_date( $context );
460 658
 
461
-        if ( $date ) {
462
-            $date = get_gmt_from_date( $date );
463
-        }
464
-		return $date;
465
-	}
466
-
467
-	/**
468
-	 * Get the subscription's trial period.
469
-	 *
470
-	 * @since 1.0.19
471
-	 * @param  string $context View or edit context.
472
-	 * @return string
473
-	 */
474
-	public function get_trial_period( $context = 'view' ) {
475
-		return $this->get_prop( 'trial_period', $context );
476
-	}
477
-
478
-	/**
479
-	 * Get the subscription's status.
480
-	 *
481
-	 * @since 1.0.19
482
-	 * @param  string $context View or edit context.
483
-	 * @return string
484
-	 */
485
-	public function get_status( $context = 'view' ) {
486
-		return $this->get_prop( 'status', $context );
487
-	}
488
-
489
-	/**
490
-	 * Get the subscription's profile id.
491
-	 *
492
-	 * @since 1.0.19
493
-	 * @param  string $context View or edit context.
494
-	 * @return string
495
-	 */
496
-	public function get_profile_id( $context = 'view' ) {
497
-		return $this->get_prop( 'profile_id', $context );
498
-	}
499
-
500
-	/*
501
-	|--------------------------------------------------------------------------
502
-	| Setters
503
-	|--------------------------------------------------------------------------
504
-	*/
659
+        $this->set_prop( 'expiration', '' );
505 660
 
506
-	/**
507
-	 * Set customer id.
508
-	 *
509
-	 * @since 1.0.19
510
-	 * @param  int $value The customer's id.
511
-	 */
512
-	public function set_customer_id( $value ) {
513
-		$this->set_prop( 'customer_id', (int) $value );
514
-	}
515
-
516
-	/**
517
-	 * Set parent invoice id.
518
-	 *
519
-	 * @since 1.0.19
520
-	 * @param  int $value The parent invoice id.
521
-	 */
522
-	public function set_parent_invoice_id( $value ) {
523
-		$this->set_prop( 'parent_payment_id', (int) $value );
524
-	}
525
-
526
-	/**
527
-	 * Alias for self::set_parent_invoice_id().
528
-	 *
529
-	 * @since 1.0.19
530
-	 * @param  int $value The parent invoice id.
531
-	 */
532
-    public function set_parent_payment_id( $value ) {
533
-        $this->set_parent_invoice_id( $value );
534
-	}
661
+    }
535 662
 
536
-	/**
537
-     * Alias for self::set_parent_invoice_id().
663
+    /**
664
+     * Alias for self::set_next_renewal_date().
538 665
      *
539 666
      * @since 1.0.19
540
-	 * @param  int $value The parent invoice id.
667
+     * @param string $value strtotime compliant date.
541 668
      */
542
-    public function set_original_payment_id( $value ) {
543
-        $this->set_parent_invoice_id( $value );
544
-	}
545
-
546
-	/**
547
-	 * Set subscription's product id.
548
-	 *
549
-	 * @since 1.0.19
550
-	 * @param  int $value The subscription product id.
551
-	 */
552
-	public function set_product_id( $value ) {
553
-		$this->set_prop( 'product_id', (int) $value );
554
-	}
555
-
556
-	/**
557
-	 * Set the period of a renewal.
558
-	 *
559
-	 * @since 1.0.19
560
-	 * @param  string $value The renewal period.
561
-	 */
562
-	public function set_period( $value ) {
563
-		$this->set_prop( 'period', $value );
564
-	}
565
-
566
-	/**
567
-	 * Set number of periods each renewal is valid for.
568
-	 *
569
-	 * @since 1.0.19
570
-	 * @param  int $value The subscription frequency.
571
-	 */
572
-	public function set_frequency( $value ) {
573
-		$value = empty( $value ) ? 1 : (int) $value;
574
-		$this->set_prop( 'frequency', absint( $value ) );
575
-	}
576
-
577
-	/**
578
-	 * Set the initial amount for the subscription.
579
-	 *
580
-	 * @since 1.0.19
581
-	 * @param  float $value The initial subcription amount.
582
-	 */
583
-	public function set_initial_amount( $value ) {
584
-		$this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) );
585
-	}
586
-
587
-	/**
588
-	 * Set the recurring amount for the subscription.
589
-	 *
590
-	 * @since 1.0.19
591
-	 * @param  float $value The recurring subcription amount.
592
-	 */
593
-	public function set_recurring_amount( $value ) {
594
-		$this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) );
595
-	}
596
-
597
-	/**
598
-	 * Set number of times that this subscription can be renewed.
599
-	 *
600
-	 * @since 1.0.19
601
-	 * @param  int $value Bill times.
602
-	 */
603
-	public function set_bill_times( $value ) {
604
-		$this->set_prop( 'bill_times', (int) $value );
605
-	}
606
-
607
-	/**
608
-	 * Get transaction id of this subscription's parent invoice.
609
-	 *
610
-	 * @since 1.0.19
611
-	 * @param string $value Bill times.
612
-	 */
613
-	public function set_transaction_id( $value ) {
614
-		$this->set_prop( 'transaction_id', sanitize_text_field( $value ) );
615
-	}
616
-
617
-	/**
618
-	 * Set date when this subscription started.
619
-	 *
620
-	 * @since 1.0.19
621
-	 * @param string $value strtotime compliant date.
622
-	 */
623
-	public function set_created( $value ) {
624
-        $date = strtotime( $value );
669
+    public function set_expiration( $value ) {
670
+        $this->set_next_renewal_date( $value );
671
+    }
625 672
 
626
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
627
-            $this->set_prop( 'created', date( 'Y-m-d H:i:s', $date ) );
673
+    /**
674
+     * Set the subscription's trial period.
675
+     *
676
+     * @since 1.0.19
677
+     * @param string $value trial period e.g 1 year.
678
+     */
679
+    public function set_trial_period( $value ) {
680
+        $this->set_prop( 'trial_period', $value );
681
+    }
682
+
683
+    /**
684
+     * Set the subscription's status.
685
+     *
686
+     * @since 1.0.19
687
+     * @param string $new_status    New subscription status.
688
+     */
689
+    public function set_status( $new_status ) {
690
+
691
+        // Abort if this is not a valid status;
692
+        if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) {
628 693
             return;
629 694
         }
630 695
 
631
-		$this->set_prop( 'created', '' );
696
+        $this->set_prop( 'status', $new_status );
632 697
 
633
-	}
698
+        $old_status = ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $this->get_status();
699
+        if ( true === $this->object_read && $old_status !== $new_status ) {
700
+            $this->status_transition = array(
701
+                'from'   => $old_status,
702
+                'to'     => $new_status,
703
+            );
704
+        }
634 705
 
635
-	/**
636
-	 * Alias for self::set_created().
637
-	 *
638
-	 * @since 1.0.19
639
-	 * @param string $value strtotime compliant date.
640
-	 */
641
-	public function set_date_created( $value ) {
642
-		$this->set_created( $value );
643 706
     }
644 707
 
645
-	/**
646
-	 * Set the date that the subscription will renew.
647
-	 *
648
-	 * @since 1.0.19
649
-	 * @param string $value strtotime compliant date.
650
-	 */
651
-	public function set_next_renewal_date( $value ) {
652
-		$date = strtotime( $value );
708
+    /**
709
+     * Set the subscription's (remote) profile id.
710
+     *
711
+     * @since 1.0.19
712
+     * @param  string $value the remote profile id.
713
+     */
714
+    public function set_profile_id( $value ) {
715
+        $this->set_prop( 'profile_id', sanitize_text_field( $value ) );
716
+    }
653 717
 
654
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
655
-            $this->set_prop( 'expiration', date( 'Y-m-d H:i:s', $date ) );
656
-            return;
657
-		}
658
-
659
-		$this->set_prop( 'expiration', '' );
660
-
661
-	}
662
-
663
-	/**
664
-	 * Alias for self::set_next_renewal_date().
665
-	 *
666
-	 * @since 1.0.19
667
-	 * @param string $value strtotime compliant date.
668
-	 */
669
-	public function set_expiration( $value ) {
670
-		$this->set_next_renewal_date( $value );
671
-    }
672
-
673
-	/**
674
-	 * Set the subscription's trial period.
675
-	 *
676
-	 * @since 1.0.19
677
-	 * @param string $value trial period e.g 1 year.
678
-	 */
679
-	public function set_trial_period( $value ) {
680
-		$this->set_prop( 'trial_period', $value );
681
-	}
682
-
683
-	/**
684
-	 * Set the subscription's status.
685
-	 *
686
-	 * @since 1.0.19
687
-	 * @param string $new_status    New subscription status.
688
-	 */
689
-	public function set_status( $new_status ) {
690
-
691
-		// Abort if this is not a valid status;
692
-		if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) {
693
-			return;
694
-		}
695
-
696
-		$this->set_prop( 'status', $new_status );
697
-
698
-		$old_status = ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $this->get_status();
699
-		if ( true === $this->object_read && $old_status !== $new_status ) {
700
-			$this->status_transition = array(
701
-				'from'   => $old_status,
702
-				'to'     => $new_status,
703
-			);
704
-		}
705
-
706
-	}
707
-
708
-	/**
709
-	 * Set the subscription's (remote) profile id.
710
-	 *
711
-	 * @since 1.0.19
712
-	 * @param  string $value the remote profile id.
713
-	 */
714
-	public function set_profile_id( $value ) {
715
-		$this->set_prop( 'profile_id', sanitize_text_field( $value ) );
716
-	}
717
-
718
-	/*
718
+    /*
719 719
 	|--------------------------------------------------------------------------
720 720
 	| Boolean methods
721 721
 	|--------------------------------------------------------------------------
@@ -724,55 +724,55 @@  discard block
 block discarded – undo
724 724
 	|
725 725
 	*/
726 726
 
727
-	/**
727
+    /**
728 728
      * Checks if the subscription has a given status.
729
-	 *
730
-	 * @param string|array String or array of strings to check for.
731
-	 * @return bool
729
+     *
730
+     * @param string|array String or array of strings to check for.
731
+     * @return bool
732 732
      */
733 733
     public function has_status( $status ) {
734 734
         return in_array( $this->get_status(), wpinv_clean( wpinv_parse_list( $status ) ) );
735
-	}
735
+    }
736 736
 
737
-	/**
737
+    /**
738 738
      * Checks if the subscription has a trial period.
739
-	 *
740
-	 * @return bool
739
+     *
740
+     * @return bool
741 741
      */
742 742
     public function has_trial_period() {
743
-		$period = $this->get_trial_period();
743
+        $period = $this->get_trial_period();
744 744
         return ! empty( $period );
745
-	}
746
-
747
-	/**
748
-	 * Is the subscription active?
749
-	 *
750
-	 * @return bool
751
-	 */
752
-	public function is_active() {
753
-		return $this->has_status( 'active trialling' ) && ! $this->is_expired();
754
-	}
755
-
756
-	/**
757
-	 * Is the subscription expired?
758
-	 *
759
-	 * @return bool
760
-	 */
761
-	public function is_expired() {
762
-		return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'mysql' ) );
763
-	}
764
-
765
-	/**
766
-	 * Is this the last renewals?
767
-	 *
768
-	 * @return bool
769
-	 */
770
-	public function is_last_renewal() {
771
-		$max_bills = $this->get_bill_times();
772
-		return ! empty( $max_bills ) && $max_bills <= $this->get_times_billed();
773
-	}
774
-
775
-	/*
745
+    }
746
+
747
+    /**
748
+     * Is the subscription active?
749
+     *
750
+     * @return bool
751
+     */
752
+    public function is_active() {
753
+        return $this->has_status( 'active trialling' ) && ! $this->is_expired();
754
+    }
755
+
756
+    /**
757
+     * Is the subscription expired?
758
+     *
759
+     * @return bool
760
+     */
761
+    public function is_expired() {
762
+        return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'mysql' ) );
763
+    }
764
+
765
+    /**
766
+     * Is this the last renewals?
767
+     *
768
+     * @return bool
769
+     */
770
+    public function is_last_renewal() {
771
+        $max_bills = $this->get_bill_times();
772
+        return ! empty( $max_bills ) && $max_bills <= $this->get_times_billed();
773
+    }
774
+
775
+    /*
776 776
 	|--------------------------------------------------------------------------
777 777
 	| Additional methods
778 778
 	|--------------------------------------------------------------------------
@@ -781,27 +781,27 @@  discard block
 block discarded – undo
781 781
 	|
782 782
 	*/
783 783
 
784
-	/**
785
-	 * Backwards compatibilty.
786
-	 */
787
-	public function create( $data = array() ) {
784
+    /**
785
+     * Backwards compatibilty.
786
+     */
787
+    public function create( $data = array() ) {
788 788
 
789
-		// Set the properties.
790
-		if ( is_array( $data ) ) {
791
-			$this->set_props( $data );
792
-		}
789
+        // Set the properties.
790
+        if ( is_array( $data ) ) {
791
+            $this->set_props( $data );
792
+        }
793 793
 
794
-		// Save the item.
795
-		return $this->save();
794
+        // Save the item.
795
+        return $this->save();
796 796
 
797
-	}
797
+    }
798 798
 
799
-	/**
800
-	 * Backwards compatibilty.
801
-	 */
802
-	public function update( $args = array() ) {
803
-		return $this->create( $args );
804
-	}
799
+    /**
800
+     * Backwards compatibilty.
801
+     */
802
+    public function update( $args = array() ) {
803
+        return $this->create( $args );
804
+    }
805 805
 
806 806
     /**
807 807
      * Retrieve renewal payments for a subscription
@@ -811,22 +811,22 @@  discard block
 block discarded – undo
811 811
      */
812 812
     public function get_child_payments( $hide_pending = true ) {
813 813
 
814
-		$statuses = array( 'publish', 'wpi-processing', 'wpi-renewal' );
814
+        $statuses = array( 'publish', 'wpi-processing', 'wpi-renewal' );
815 815
 
816
-		if ( ! $hide_pending ) {
817
-			$statuses = array_keys( wpinv_get_invoice_statuses() );
818
-		}
816
+        if ( ! $hide_pending ) {
817
+            $statuses = array_keys( wpinv_get_invoice_statuses() );
818
+        }
819 819
 
820 820
         return get_posts(
821
-			array(
822
-            	'post_parent'    => $this->get_parent_payment_id(),
823
-            	'numberposts'    => -1,
824
-            	'post_status'    => $statuses,
825
-            	'orderby'        => 'ID',
826
-            	'order'          => 'ASC',
827
-            	'post_type'      => 'wpi_invoice'
828
-			)
829
-		);
821
+            array(
822
+                'post_parent'    => $this->get_parent_payment_id(),
823
+                'numberposts'    => -1,
824
+                'post_status'    => $statuses,
825
+                'orderby'        => 'ID',
826
+                'order'          => 'ASC',
827
+                'post_type'      => 'wpi_invoice'
828
+            )
829
+        );
830 830
     }
831 831
 
832 832
     /**
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
      * @return int
837 837
      */
838 838
     public function get_total_payments() {
839
-		return getpaid_count_subscription_invoices( $this->get_parent_invoice_id(), $this->get_id() );
839
+        return getpaid_count_subscription_invoices( $this->get_parent_invoice_id(), $this->get_id() );
840 840
     }
841 841
 
842 842
     /**
@@ -860,57 +860,57 @@  discard block
 block discarded – undo
860 860
      *
861 861
      * @since  2.4
862 862
      * @param  array $args Array of values for the payment, including amount and transaction ID
863
-	 * @param  WPInv_Invoice $invoice If adding an existing invoice.
863
+     * @param  WPInv_Invoice $invoice If adding an existing invoice.
864 864
      * @return bool
865 865
      */
866 866
     public function add_payment( $args = array(), $invoice = false ) {
867 867
 
868
-		// Process each payment once.
868
+        // Process each payment once.
869 869
         if ( ! empty( $args['transaction_id'] ) && $this->payment_exists( $args['transaction_id'] ) ) {
870 870
             return false;
871 871
         }
872 872
 
873
-		// Are we creating a new invoice?
874
-		if ( empty( $invoice ) ) {
875
-			$invoice = $this->create_payment();
873
+        // Are we creating a new invoice?
874
+        if ( empty( $invoice ) ) {
875
+            $invoice = $this->create_payment();
876 876
 
877
-			if ( empty( $invoice ) ) {
878
-				return false;
879
-			}
877
+            if ( empty( $invoice ) ) {
878
+                return false;
879
+            }
880 880
 
881
-		}
881
+        }
882 882
 
883
-		$invoice->set_status( 'wpi-renewal' );
883
+        $invoice->set_status( 'wpi-renewal' );
884 884
 
885
-		// Maybe set a transaction id.
886
-		if ( ! empty( $args['transaction_id'] ) ) {
887
-			$invoice->set_transaction_id( $args['transaction_id'] );
888
-		}
885
+        // Maybe set a transaction id.
886
+        if ( ! empty( $args['transaction_id'] ) ) {
887
+            $invoice->set_transaction_id( $args['transaction_id'] );
888
+        }
889 889
 
890
-		// Set the completed date.
891
-		$invoice->set_completed_date( current_time( 'mysql' ) );
890
+        // Set the completed date.
891
+        $invoice->set_completed_date( current_time( 'mysql' ) );
892 892
 
893
-		// And the gateway.
894
-		if ( ! empty( $args['gateway'] ) ) {
895
-			$invoice->set_gateway( $args['gateway'] );
896
-		}
893
+        // And the gateway.
894
+        if ( ! empty( $args['gateway'] ) ) {
895
+            $invoice->set_gateway( $args['gateway'] );
896
+        }
897 897
 
898
-		$invoice->save();
898
+        $invoice->save();
899 899
 
900
-		if ( ! $invoice->exists() ) {
901
-			return false;
902
-		}
900
+        if ( ! $invoice->exists() ) {
901
+            return false;
902
+        }
903 903
 
904
-		do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this );
905
-		do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this );
904
+        do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this );
905
+        do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this );
906 906
         do_action( 'wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id() );
907 907
 
908 908
         update_post_meta( $invoice->get_id(), '_wpinv_subscription_id', $this->id );
909 909
 
910 910
         return $invoice->get_id();
911
-	}
911
+    }
912 912
 
913
-	/**
913
+    /**
914 914
      * Creates a new invoice and returns it.
915 915
      *
916 916
      * @since  1.0.19
@@ -918,124 +918,124 @@  discard block
 block discarded – undo
918 918
      */
919 919
     public function create_payment() {
920 920
 
921
-		$parent_invoice = $this->get_parent_payment();
922
-
923
-		if ( ! $parent_invoice->exists() ) {
924
-			return false;
925
-		}
926
-
927
-		// Duplicate the parent invoice.
928
-		$invoice = getpaid_duplicate_invoice( $parent_invoice );
929
-		$invoice->set_parent_id( $parent_invoice->get_id() );
930
-		$invoice->set_subscription_id( $this->get_id() );
931
-		$invoice->set_remote_subscription_id( $this->get_profile_id() );
932
-
933
-		// Set invoice items.
934
-		$subscription_group = getpaid_get_invoice_subscription_group( $parent_invoice->get_id(), $this->get_id() );
935
-		$allowed_items      = empty( $subscription_group ) ? array( $this->get_product_id() ) : array_keys( $subscription_group['items'] );
936
-		$invoice_items      = array();
937
-
938
-		foreach ( $invoice->get_items() as $item ) {
939
-			if ( in_array( $item->get_id(), $allowed_items ) ) {
940
-				$invoice_items[] = $item;
941
-			}
942
-		}
943
-
944
-		$invoice->set_items( $invoice_items );
945
-
946
-		if ( ! empty( $subscription_group['fees'] ) ) {
947
-			$invoice->set_fees( $subscription_group['fees'] );
948
-		}
949
-
950
-		// Maybe recalculate discount (Pre-GetPaid Fix).
951
-		$discount = new WPInv_Discount( $invoice->get_discount_code() );
952
-		if ( $discount->exists() && $discount->is_recurring() && 0 == $invoice->get_total_discount() ) {
953
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
954
-		}
955
-
956
-		$invoice->recalculate_total();
957
-		$invoice->set_status( 'wpi-pending' );
958
-		$invoice->save();
959
-
960
-		return $invoice->exists() ? $invoice : false;
961
-    }
962
-
963
-	/**
964
-	 * Renews or completes a subscription
965
-	 *
966
-	 * @since  1.0.0
967
-	 * @return int The subscription's id
968
-	 */
969
-	public function renew() {
970
-
971
-		// Complete subscription if applicable
972
-		if ( $this->is_last_renewal() ) {
973
-			return $this->complete();
974
-		}
975
-
976
-		// Calculate new expiration
977
-		$frequency      = $this->get_frequency();
978
-		$period         = $this->get_period();
979
-		$new_expiration = strtotime( "+ $frequency $period", $this->get_expiration_time() );
980
-
981
-		$this->set_expiration( date( 'Y-m-d H:i:s',$new_expiration ) );
982
-		$this->set_status( 'active' );
983
-		$this->save();
984
-
985
-		do_action( 'getpaid_subscription_renewed', $this );
986
-
987
-		return $this->get_id();
988
-	}
989
-
990
-	/**
991
-	 * Marks a subscription as completed
992
-	 *
993
-	 * Subscription is completed when the number of payments matches the billing_times field
994
-	 *
995
-	 * @since  1.0.0
996
-	 * @return int|bool Subscription id or false if the subscription is cancelled.
997
-	 */
998
-	public function complete() {
999
-
1000
-		// Only mark a subscription as complete if it's not already cancelled.
1001
-		if ( $this->has_status( 'cancelled' ) ) {
1002
-			return false;
1003
-		}
1004
-
1005
-		$this->set_status( 'completed' );
1006
-		return $this->save();
1007
-
1008
-	}
1009
-
1010
-	/**
1011
-	 * Marks a subscription as expired
1012
-	 *
1013
-	 * @since  1.0.0
1014
-	 * @param  bool $check_expiration
1015
-	 * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future.
1016
-	 */
1017
-	public function expire( $check_expiration = false ) {
1018
-
1019
-		if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) {
1020
-			// Do not mark as expired since real expiration date is in the future
1021
-			return false;
1022
-		}
1023
-
1024
-		$this->set_status( 'expired' );
1025
-		return $this->save();
1026
-
1027
-	}
1028
-
1029
-	/**
1030
-	 * Marks a subscription as failing
1031
-	 *
1032
-	 * @since  2.4.2
1033
-	 * @return int Subscription id.
1034
-	 */
1035
-	public function failing() {
1036
-		$this->set_status( 'failing' );
1037
-		return $this->save();
1038
-	}
921
+        $parent_invoice = $this->get_parent_payment();
922
+
923
+        if ( ! $parent_invoice->exists() ) {
924
+            return false;
925
+        }
926
+
927
+        // Duplicate the parent invoice.
928
+        $invoice = getpaid_duplicate_invoice( $parent_invoice );
929
+        $invoice->set_parent_id( $parent_invoice->get_id() );
930
+        $invoice->set_subscription_id( $this->get_id() );
931
+        $invoice->set_remote_subscription_id( $this->get_profile_id() );
932
+
933
+        // Set invoice items.
934
+        $subscription_group = getpaid_get_invoice_subscription_group( $parent_invoice->get_id(), $this->get_id() );
935
+        $allowed_items      = empty( $subscription_group ) ? array( $this->get_product_id() ) : array_keys( $subscription_group['items'] );
936
+        $invoice_items      = array();
937
+
938
+        foreach ( $invoice->get_items() as $item ) {
939
+            if ( in_array( $item->get_id(), $allowed_items ) ) {
940
+                $invoice_items[] = $item;
941
+            }
942
+        }
943
+
944
+        $invoice->set_items( $invoice_items );
945
+
946
+        if ( ! empty( $subscription_group['fees'] ) ) {
947
+            $invoice->set_fees( $subscription_group['fees'] );
948
+        }
949
+
950
+        // Maybe recalculate discount (Pre-GetPaid Fix).
951
+        $discount = new WPInv_Discount( $invoice->get_discount_code() );
952
+        if ( $discount->exists() && $discount->is_recurring() && 0 == $invoice->get_total_discount() ) {
953
+            $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
954
+        }
955
+
956
+        $invoice->recalculate_total();
957
+        $invoice->set_status( 'wpi-pending' );
958
+        $invoice->save();
959
+
960
+        return $invoice->exists() ? $invoice : false;
961
+    }
962
+
963
+    /**
964
+     * Renews or completes a subscription
965
+     *
966
+     * @since  1.0.0
967
+     * @return int The subscription's id
968
+     */
969
+    public function renew() {
970
+
971
+        // Complete subscription if applicable
972
+        if ( $this->is_last_renewal() ) {
973
+            return $this->complete();
974
+        }
975
+
976
+        // Calculate new expiration
977
+        $frequency      = $this->get_frequency();
978
+        $period         = $this->get_period();
979
+        $new_expiration = strtotime( "+ $frequency $period", $this->get_expiration_time() );
980
+
981
+        $this->set_expiration( date( 'Y-m-d H:i:s',$new_expiration ) );
982
+        $this->set_status( 'active' );
983
+        $this->save();
984
+
985
+        do_action( 'getpaid_subscription_renewed', $this );
986
+
987
+        return $this->get_id();
988
+    }
989
+
990
+    /**
991
+     * Marks a subscription as completed
992
+     *
993
+     * Subscription is completed when the number of payments matches the billing_times field
994
+     *
995
+     * @since  1.0.0
996
+     * @return int|bool Subscription id or false if the subscription is cancelled.
997
+     */
998
+    public function complete() {
999
+
1000
+        // Only mark a subscription as complete if it's not already cancelled.
1001
+        if ( $this->has_status( 'cancelled' ) ) {
1002
+            return false;
1003
+        }
1004
+
1005
+        $this->set_status( 'completed' );
1006
+        return $this->save();
1007
+
1008
+    }
1009
+
1010
+    /**
1011
+     * Marks a subscription as expired
1012
+     *
1013
+     * @since  1.0.0
1014
+     * @param  bool $check_expiration
1015
+     * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future.
1016
+     */
1017
+    public function expire( $check_expiration = false ) {
1018
+
1019
+        if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) {
1020
+            // Do not mark as expired since real expiration date is in the future
1021
+            return false;
1022
+        }
1023
+
1024
+        $this->set_status( 'expired' );
1025
+        return $this->save();
1026
+
1027
+    }
1028
+
1029
+    /**
1030
+     * Marks a subscription as failing
1031
+     *
1032
+     * @since  2.4.2
1033
+     * @return int Subscription id.
1034
+     */
1035
+    public function failing() {
1036
+        $this->set_status( 'failing' );
1037
+        return $this->save();
1038
+    }
1039 1039
 
1040 1040
     /**
1041 1041
      * Marks a subscription as cancelled
@@ -1044,19 +1044,19 @@  discard block
 block discarded – undo
1044 1044
      * @return int Subscription id.
1045 1045
      */
1046 1046
     public function cancel() {
1047
-		$this->set_status( 'cancelled' );
1048
-		return $this->save();
1047
+        $this->set_status( 'cancelled' );
1048
+        return $this->save();
1049 1049
     }
1050 1050
 
1051
-	/**
1052
-	 * Determines if a subscription can be cancelled both locally and with a payment processor.
1053
-	 *
1054
-	 * @since  1.0.0
1055
-	 * @return bool
1056
-	 */
1057
-	public function can_cancel() {
1058
-		return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this );
1059
-	}
1051
+    /**
1052
+     * Determines if a subscription can be cancelled both locally and with a payment processor.
1053
+     *
1054
+     * @since  1.0.0
1055
+     * @return bool
1056
+     */
1057
+    public function can_cancel() {
1058
+        return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this );
1059
+    }
1060 1060
 
1061 1061
     /**
1062 1062
      * Returns an array of subscription statuses that can be cancelled
@@ -1069,96 +1069,96 @@  discard block
 block discarded – undo
1069 1069
         return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) );
1070 1070
     }
1071 1071
 
1072
-	/**
1073
-	 * Retrieves the URL to cancel subscription
1074
-	 *
1075
-	 * @since  1.0.0
1076
-	 * @return string
1077
-	 */
1078
-	public function get_cancel_url() {
1079
-		$url = getpaid_get_authenticated_action_url( 'subscription_cancel', $this->get_view_url() );
1080
-		return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
1081
-	}
1082
-
1083
-	/**
1084
-	 * Retrieves the URL to view a subscription
1085
-	 *
1086
-	 * @since  1.0.19
1087
-	 * @return string
1088
-	 */
1089
-	public function get_view_url() {
1090
-
1091
-		$url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) );
1092
-		$url = add_query_arg( 'subscription', $this->get_id(), $url );
1093
-
1094
-		return apply_filters( 'getpaid_get_subscription_view_url', $url, $this );
1095
-	}
1096
-
1097
-	/**
1098
-	 * Determines if subscription can be manually renewed
1099
-	 *
1100
-	 * This method is filtered by payment gateways in order to return true on subscriptions
1101
-	 * that can be renewed manually
1102
-	 *
1103
-	 * @since  2.5
1104
-	 * @return bool
1105
-	 */
1106
-	public function can_renew() {
1107
-		return apply_filters( 'wpinv_subscription_can_renew', true, $this );
1108
-	}
1109
-
1110
-	/**
1111
-	 * Retrieves the URL to renew a subscription
1112
-	 *
1113
-	 * @since  2.5
1114
-	 * @return string
1115
-	 */
1116
-	public function get_renew_url() {
1117
-		$url = wp_nonce_url( add_query_arg( array( 'getpaid-action' => 'renew_subscription', 'sub_id' => $this->get_id ) ), 'getpaid-nonce' );
1118
-		return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
1119
-	}
1120
-
1121
-	/**
1122
-	 * Determines if subscription can have their payment method updated
1123
-	 *
1124
-	 * @since  1.0.0
1125
-	 * @return bool
1126
-	 */
1127
-	public function can_update() {
1128
-		return apply_filters( 'wpinv_subscription_can_update', false, $this );
1129
-	}
1130
-
1131
-	/**
1132
-	 * Retrieves the URL to update subscription
1133
-	 *
1134
-	 * @since  1.0.0
1135
-	 * @return string
1136
-	 */
1137
-	public function get_update_url() {
1138
-		$url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->get_id() ) );
1139
-		return apply_filters( 'wpinv_subscription_update_url', $url, $this );
1140
-	}
1141
-
1142
-	/**
1143
-	 * Retrieves the subscription status label
1144
-	 *
1145
-	 * @since  1.0.0
1146
-	 * @return string
1147
-	 */
1148
-	public function get_status_label() {
1149
-		return getpaid_get_subscription_status_label( $this->get_status() );
1150
-	}
1151
-
1152
-	/**
1153
-	 * Retrieves the subscription status class
1154
-	 *
1155
-	 * @since  1.0.19
1156
-	 * @return string
1157
-	 */
1158
-	public function get_status_class() {
1159
-		$statuses = getpaid_get_subscription_status_classes();
1160
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark';
1161
-	}
1072
+    /**
1073
+     * Retrieves the URL to cancel subscription
1074
+     *
1075
+     * @since  1.0.0
1076
+     * @return string
1077
+     */
1078
+    public function get_cancel_url() {
1079
+        $url = getpaid_get_authenticated_action_url( 'subscription_cancel', $this->get_view_url() );
1080
+        return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
1081
+    }
1082
+
1083
+    /**
1084
+     * Retrieves the URL to view a subscription
1085
+     *
1086
+     * @since  1.0.19
1087
+     * @return string
1088
+     */
1089
+    public function get_view_url() {
1090
+
1091
+        $url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) );
1092
+        $url = add_query_arg( 'subscription', $this->get_id(), $url );
1093
+
1094
+        return apply_filters( 'getpaid_get_subscription_view_url', $url, $this );
1095
+    }
1096
+
1097
+    /**
1098
+     * Determines if subscription can be manually renewed
1099
+     *
1100
+     * This method is filtered by payment gateways in order to return true on subscriptions
1101
+     * that can be renewed manually
1102
+     *
1103
+     * @since  2.5
1104
+     * @return bool
1105
+     */
1106
+    public function can_renew() {
1107
+        return apply_filters( 'wpinv_subscription_can_renew', true, $this );
1108
+    }
1109
+
1110
+    /**
1111
+     * Retrieves the URL to renew a subscription
1112
+     *
1113
+     * @since  2.5
1114
+     * @return string
1115
+     */
1116
+    public function get_renew_url() {
1117
+        $url = wp_nonce_url( add_query_arg( array( 'getpaid-action' => 'renew_subscription', 'sub_id' => $this->get_id ) ), 'getpaid-nonce' );
1118
+        return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
1119
+    }
1120
+
1121
+    /**
1122
+     * Determines if subscription can have their payment method updated
1123
+     *
1124
+     * @since  1.0.0
1125
+     * @return bool
1126
+     */
1127
+    public function can_update() {
1128
+        return apply_filters( 'wpinv_subscription_can_update', false, $this );
1129
+    }
1130
+
1131
+    /**
1132
+     * Retrieves the URL to update subscription
1133
+     *
1134
+     * @since  1.0.0
1135
+     * @return string
1136
+     */
1137
+    public function get_update_url() {
1138
+        $url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->get_id() ) );
1139
+        return apply_filters( 'wpinv_subscription_update_url', $url, $this );
1140
+    }
1141
+
1142
+    /**
1143
+     * Retrieves the subscription status label
1144
+     *
1145
+     * @since  1.0.0
1146
+     * @return string
1147
+     */
1148
+    public function get_status_label() {
1149
+        return getpaid_get_subscription_status_label( $this->get_status() );
1150
+    }
1151
+
1152
+    /**
1153
+     * Retrieves the subscription status class
1154
+     *
1155
+     * @since  1.0.19
1156
+     * @return string
1157
+     */
1158
+    public function get_status_class() {
1159
+        $statuses = getpaid_get_subscription_status_classes();
1160
+        return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark';
1161
+    }
1162 1162
 
1163 1163
     /**
1164 1164
      * Retrieves the subscription status label
@@ -1168,11 +1168,11 @@  discard block
 block discarded – undo
1168 1168
      */
1169 1169
     public function get_status_label_html() {
1170 1170
 
1171
-		$status_label = sanitize_text_field( $this->get_status_label() );
1172
-		$class        = esc_attr( $this->get_status_class() );
1173
-		$status       = sanitize_html_class( $this->get_status() );
1171
+        $status_label = sanitize_text_field( $this->get_status_label() );
1172
+        $class        = esc_attr( $this->get_status_class() );
1173
+        $status       = sanitize_html_class( $this->get_status() );
1174 1174
 
1175
-		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
1175
+        return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
1176 1176
     }
1177 1177
 
1178 1178
     /**
@@ -1183,75 +1183,75 @@  discard block
 block discarded – undo
1183 1183
      * @return bool
1184 1184
      */
1185 1185
     public function payment_exists( $txn_id = '' ) {
1186
-		$invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' );
1186
+        $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' );
1187 1187
         return ! empty( $invoice_id );
1188
-	}
1189
-
1190
-	/**
1191
-	 * Handle the status transition.
1192
-	 */
1193
-	protected function status_transition() {
1194
-		$status_transition = $this->status_transition;
1195
-
1196
-		// Reset status transition variable.
1197
-		$this->status_transition = false;
1198
-
1199
-		if ( $status_transition ) {
1200
-			try {
1201
-
1202
-				// Fire a hook for the status change.
1203
-				do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
1204
-				do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition );
1205
-
1206
-				if ( ! empty( $status_transition['from'] ) ) {
1207
-
1208
-					/* translators: 1: old subscription status 2: new subscription status */
1209
-					$transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1210
-
1211
-					// Note the transition occurred.
1212
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1213
-
1214
-					// Fire another hook.
1215
-					do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
1216
-					do_action( 'getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to'] );
1217
-
1218
-				} else {
1219
-					/* translators: %s: new invoice status */
1220
-					$transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1221
-
1222
-					// Note the transition occurred.
1223
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1224
-
1225
-				}
1226
-			} catch ( Exception $e ) {
1227
-				$this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
1228
-			}
1229
-		}
1230
-
1231
-	}
1232
-
1233
-	/**
1234
-	 * Save data to the database.
1235
-	 *
1236
-	 * @since 1.0.19
1237
-	 * @return int subscription ID
1238
-	 */
1239
-	public function save() {
1240
-		parent::save();
1241
-		$this->status_transition();
1242
-		return $this->get_id();
1243
-	}
1244
-
1245
-	/**
1246
-	 * Activates a subscription.
1247
-	 *
1248
-	 * @since 1.0.19
1249
-	 * @return int subscription ID
1250
-	 */
1251
-	public function activate() {
1252
-		$status = 'trialling' == $this->get_status() ? 'trialling' : 'active';
1253
-		$this->set_status( $status );
1254
-		return $this->save();
1255
-	}
1188
+    }
1189
+
1190
+    /**
1191
+     * Handle the status transition.
1192
+     */
1193
+    protected function status_transition() {
1194
+        $status_transition = $this->status_transition;
1195
+
1196
+        // Reset status transition variable.
1197
+        $this->status_transition = false;
1198
+
1199
+        if ( $status_transition ) {
1200
+            try {
1201
+
1202
+                // Fire a hook for the status change.
1203
+                do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
1204
+                do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition );
1205
+
1206
+                if ( ! empty( $status_transition['from'] ) ) {
1207
+
1208
+                    /* translators: 1: old subscription status 2: new subscription status */
1209
+                    $transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1210
+
1211
+                    // Note the transition occurred.
1212
+                    $this->get_parent_payment()->add_note( $transition_note, false, false, true );
1213
+
1214
+                    // Fire another hook.
1215
+                    do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
1216
+                    do_action( 'getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to'] );
1217
+
1218
+                } else {
1219
+                    /* translators: %s: new invoice status */
1220
+                    $transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1221
+
1222
+                    // Note the transition occurred.
1223
+                    $this->get_parent_payment()->add_note( $transition_note, false, false, true );
1224
+
1225
+                }
1226
+            } catch ( Exception $e ) {
1227
+                $this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
1228
+            }
1229
+        }
1230
+
1231
+    }
1232
+
1233
+    /**
1234
+     * Save data to the database.
1235
+     *
1236
+     * @since 1.0.19
1237
+     * @return int subscription ID
1238
+     */
1239
+    public function save() {
1240
+        parent::save();
1241
+        $this->status_transition();
1242
+        return $this->get_id();
1243
+    }
1244
+
1245
+    /**
1246
+     * Activates a subscription.
1247
+     *
1248
+     * @since 1.0.19
1249
+     * @return int subscription ID
1250
+     */
1251
+    public function activate() {
1252
+        $status = 'trialling' == $this->get_status() ? 'trialling' : 'active';
1253
+        $this->set_status( $status );
1254
+        return $this->save();
1255
+    }
1256 1256
 
1257 1257
 }
Please login to merge, or discard this patch.
Spacing   +230 added lines, -230 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * The Subscription Class
@@ -68,27 +68,27 @@  discard block
 block discarded – undo
68 68
 	 * @param  int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read.
69 69
 	 * @param  bool $deprecated
70 70
 	 */
71
-	function __construct( $subscription = 0, $deprecated = false ) {
71
+	function __construct($subscription = 0, $deprecated = false) {
72 72
 
73
-		parent::__construct( $subscription );
73
+		parent::__construct($subscription);
74 74
 
75
-		if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) {
76
-			$this->set_id( $subscription );
77
-		} elseif ( $subscription instanceof self ) {
78
-			$this->set_id( $subscription->get_id() );
79
-		} elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) {
80
-			$this->set_id( $subscription_id );
81
-		} elseif ( ! empty( $subscription->id ) ) {
82
-			$this->set_id( $subscription->id );
75
+		if (!$deprecated && !empty($subscription) && is_numeric($subscription)) {
76
+			$this->set_id($subscription);
77
+		} elseif ($subscription instanceof self) {
78
+			$this->set_id($subscription->get_id());
79
+		} elseif ($deprecated && $subscription_id = self::get_subscription_id_by_field($subscription, 'profile_id')) {
80
+			$this->set_id($subscription_id);
81
+		} elseif (!empty($subscription->id)) {
82
+			$this->set_id($subscription->id);
83 83
 		} else {
84
-			$this->set_object_read( true );
84
+			$this->set_object_read(true);
85 85
 		}
86 86
 
87 87
 		// Load the datastore.
88
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
88
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
89 89
 
90
-		if ( $this->get_id() > 0 ) {
91
-			$this->data_store->read( $this );
90
+		if ($this->get_id() > 0) {
91
+			$this->data_store->read($this);
92 92
 		}
93 93
 
94 94
 	}
@@ -103,17 +103,17 @@  discard block
 block discarded – undo
103 103
 	 * @since 1.0.19
104 104
 	 * @return int
105 105
 	 */
106
-	public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) {
106
+	public static function get_subscription_id_by_field($value, $field = 'profile_id') {
107 107
         global $wpdb;
108 108
 
109 109
 		// Trim the value.
110
-		$value = trim( $value );
110
+		$value = trim($value);
111 111
 
112
-		if ( empty( $value ) ) {
112
+		if (empty($value)) {
113 113
 			return 0;
114 114
 		}
115 115
 
116
-		if ( 'invoice_id' == $field ) {
116
+		if ('invoice_id' == $field) {
117 117
 			$field = 'parent_payment_id';
118 118
 		}
119 119
 
@@ -125,28 +125,28 @@  discard block
 block discarded – undo
125 125
 		);
126 126
 
127 127
 		// Ensure a field has been passed.
128
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
128
+		if (empty($field) || !in_array($field, $fields)) {
129 129
 			return 0;
130 130
 		}
131 131
 
132 132
 		// Maybe retrieve from the cache.
133
-		$subscription_id   = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" );
134
-		if ( ! empty( $subscription_id ) ) {
133
+		$subscription_id = wp_cache_get($value, "getpaid_subscription_{$field}s_to_subscription_ids");
134
+		if (!empty($subscription_id)) {
135 135
 			return $subscription_id;
136 136
 		}
137 137
 
138 138
         // Fetch from the db.
139 139
         $table            = $wpdb->prefix . 'wpinv_subscriptions';
140 140
         $subscription_id  = (int) $wpdb->get_var(
141
-            $wpdb->prepare( "SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
141
+            $wpdb->prepare("SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value)
142 142
         );
143 143
 
144
-		if ( empty( $subscription_id ) ) {
144
+		if (empty($subscription_id)) {
145 145
 			return 0;
146 146
 		}
147 147
 
148 148
 		// Update the cache with our data.
149
-		wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" );
149
+		wp_cache_set($value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids");
150 150
 
151 151
 		return $subscription_id;
152 152
 	}
@@ -155,17 +155,17 @@  discard block
 block discarded – undo
155 155
      * Clears the subscription's cache.
156 156
      */
157 157
     public function clear_cache() {
158
-		wp_cache_delete( $this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids' );
159
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids' );
160
-		wp_cache_delete( $this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids' );
161
-		wp_cache_delete( $this->get_id(), 'getpaid_subscriptions' );
158
+		wp_cache_delete($this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids');
159
+		wp_cache_delete($this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids');
160
+		wp_cache_delete($this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids');
161
+		wp_cache_delete($this->get_id(), 'getpaid_subscriptions');
162 162
 	}
163 163
 
164 164
 	/**
165 165
      * Checks if a subscription key is set.
166 166
      */
167
-    public function _isset( $key ) {
168
-        return isset( $this->data[$key] ) || method_exists( $this, "get_$key" );
167
+    public function _isset($key) {
168
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
169 169
 	}
170 170
 
171 171
 	/*
@@ -190,8 +190,8 @@  discard block
 block discarded – undo
190 190
 	 * @param  string $context View or edit context.
191 191
 	 * @return int
192 192
 	 */
193
-	public function get_customer_id( $context = 'view' ) {
194
-		return (int) $this->get_prop( 'customer_id', $context );
193
+	public function get_customer_id($context = 'view') {
194
+		return (int) $this->get_prop('customer_id', $context);
195 195
 	}
196 196
 
197 197
 	/**
@@ -201,8 +201,8 @@  discard block
 block discarded – undo
201 201
 	 * @param  string $context View or edit context.
202 202
 	 * @return WP_User|false WP_User object on success, false on failure.
203 203
 	 */
204
-	public function get_customer( $context = 'view' ) {
205
-		return get_userdata( $this->get_customer_id( $context ) );
204
+	public function get_customer($context = 'view') {
205
+		return get_userdata($this->get_customer_id($context));
206 206
 	}
207 207
 
208 208
 	/**
@@ -212,8 +212,8 @@  discard block
 block discarded – undo
212 212
 	 * @param  string $context View or edit context.
213 213
 	 * @return int
214 214
 	 */
215
-	public function get_parent_invoice_id( $context = 'view' ) {
216
-		return (int) $this->get_prop( 'parent_payment_id', $context );
215
+	public function get_parent_invoice_id($context = 'view') {
216
+		return (int) $this->get_prop('parent_payment_id', $context);
217 217
 	}
218 218
 
219 219
 	/**
@@ -223,8 +223,8 @@  discard block
 block discarded – undo
223 223
 	 * @param  string $context View or edit context.
224 224
 	 * @return int
225 225
 	 */
226
-    public function get_parent_payment_id( $context = 'view' ) {
227
-        return $this->get_parent_invoice_id( $context );
226
+    public function get_parent_payment_id($context = 'view') {
227
+        return $this->get_parent_invoice_id($context);
228 228
 	}
229 229
 
230 230
 	/**
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
      * @since  1.0.0
234 234
      * @return int
235 235
      */
236
-    public function get_original_payment_id( $context = 'view' ) {
237
-        return $this->get_parent_invoice_id( $context );
236
+    public function get_original_payment_id($context = 'view') {
237
+        return $this->get_parent_invoice_id($context);
238 238
     }
239 239
 
240 240
 	/**
@@ -244,8 +244,8 @@  discard block
 block discarded – undo
244 244
 	 * @param  string $context View or edit context.
245 245
 	 * @return WPInv_Invoice
246 246
 	 */
247
-	public function get_parent_invoice( $context = 'view' ) {
248
-		return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) );
247
+	public function get_parent_invoice($context = 'view') {
248
+		return new WPInv_Invoice($this->get_parent_invoice_id($context));
249 249
 	}
250 250
 
251 251
 	/**
@@ -255,8 +255,8 @@  discard block
 block discarded – undo
255 255
 	 * @param  string $context View or edit context.
256 256
 	 * @return WPInv_Invoice
257 257
 	 */
258
-    public function get_parent_payment( $context = 'view' ) {
259
-        return $this->get_parent_invoice( $context );
258
+    public function get_parent_payment($context = 'view') {
259
+        return $this->get_parent_invoice($context);
260 260
 	}
261 261
 
262 262
 	/**
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
 	 * @param  string $context View or edit context.
267 267
 	 * @return int
268 268
 	 */
269
-	public function get_product_id( $context = 'view' ) {
270
-		return (int) $this->get_prop( 'product_id', $context );
269
+	public function get_product_id($context = 'view') {
270
+		return (int) $this->get_prop('product_id', $context);
271 271
 	}
272 272
 
273 273
 	/**
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
 	 * @param  string $context View or edit context.
278 278
 	 * @return WPInv_Item
279 279
 	 */
280
-	public function get_product( $context = 'view' ) {
281
-		return new WPInv_Item( $this->get_product_id( $context ) );
280
+	public function get_product($context = 'view') {
281
+		return new WPInv_Item($this->get_product_id($context));
282 282
 	}
283 283
 
284 284
 	/**
@@ -290,8 +290,8 @@  discard block
 block discarded – undo
290 290
 	 * @param  string $context View or edit context.
291 291
 	 * @return string
292 292
 	 */
293
-	public function get_gateway( $context = 'view' ) {
294
-		return $this->get_parent_invoice( $context )->get_gateway();
293
+	public function get_gateway($context = 'view') {
294
+		return $this->get_parent_invoice($context)->get_gateway();
295 295
 	}
296 296
 
297 297
 	/**
@@ -301,8 +301,8 @@  discard block
 block discarded – undo
301 301
 	 * @param  string $context View or edit context.
302 302
 	 * @return string
303 303
 	 */
304
-	public function get_period( $context = 'view' ) {
305
-		return $this->get_prop( 'period', $context );
304
+	public function get_period($context = 'view') {
305
+		return $this->get_prop('period', $context);
306 306
 	}
307 307
 
308 308
 	/**
@@ -312,8 +312,8 @@  discard block
 block discarded – undo
312 312
 	 * @param  string $context View or edit context.
313 313
 	 * @return int
314 314
 	 */
315
-	public function get_frequency( $context = 'view' ) {
316
-		return (int) $this->get_prop( 'frequency', $context );
315
+	public function get_frequency($context = 'view') {
316
+		return (int) $this->get_prop('frequency', $context);
317 317
 	}
318 318
 
319 319
 	/**
@@ -323,8 +323,8 @@  discard block
 block discarded – undo
323 323
 	 * @param  string $context View or edit context.
324 324
 	 * @return float
325 325
 	 */
326
-	public function get_initial_amount( $context = 'view' ) {
327
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) );
326
+	public function get_initial_amount($context = 'view') {
327
+		return (float) wpinv_sanitize_amount($this->get_prop('initial_amount', $context));
328 328
 	}
329 329
 
330 330
 	/**
@@ -334,8 +334,8 @@  discard block
 block discarded – undo
334 334
 	 * @param  string $context View or edit context.
335 335
 	 * @return float
336 336
 	 */
337
-	public function get_recurring_amount( $context = 'view' ) {
338
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) );
337
+	public function get_recurring_amount($context = 'view') {
338
+		return (float) wpinv_sanitize_amount($this->get_prop('recurring_amount', $context));
339 339
 	}
340 340
 
341 341
 	/**
@@ -345,8 +345,8 @@  discard block
 block discarded – undo
345 345
 	 * @param  string $context View or edit context.
346 346
 	 * @return int
347 347
 	 */
348
-	public function get_bill_times( $context = 'view' ) {
349
-		return (int) $this->get_prop( 'bill_times', $context );
348
+	public function get_bill_times($context = 'view') {
349
+		return (int) $this->get_prop('bill_times', $context);
350 350
 	}
351 351
 
352 352
 	/**
@@ -356,8 +356,8 @@  discard block
 block discarded – undo
356 356
 	 * @param  string $context View or edit context.
357 357
 	 * @return string
358 358
 	 */
359
-	public function get_transaction_id( $context = 'view' ) {
360
-		return $this->get_prop( 'transaction_id', $context );
359
+	public function get_transaction_id($context = 'view') {
360
+		return $this->get_prop('transaction_id', $context);
361 361
 	}
362 362
 
363 363
 	/**
@@ -367,8 +367,8 @@  discard block
 block discarded – undo
367 367
 	 * @param  string $context View or edit context.
368 368
 	 * @return string
369 369
 	 */
370
-	public function get_created( $context = 'view' ) {
371
-		return $this->get_prop( 'created', $context );
370
+	public function get_created($context = 'view') {
371
+		return $this->get_prop('created', $context);
372 372
 	}
373 373
 
374 374
 	/**
@@ -378,8 +378,8 @@  discard block
 block discarded – undo
378 378
 	 * @param  string $context View or edit context.
379 379
 	 * @return string
380 380
 	 */
381
-	public function get_date_created( $context = 'view' ) {
382
-		return $this->get_created( $context );
381
+	public function get_date_created($context = 'view') {
382
+		return $this->get_created($context);
383 383
 	}
384 384
 
385 385
 	/**
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 	 */
391 391
 	public function get_time_created() {
392 392
 		$created = $this->get_date_created();
393
-		return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) );
393
+		return empty($created) ? current_time('timestamp') : strtotime($created, current_time('timestamp'));
394 394
 	}
395 395
 
396 396
 	/**
@@ -400,11 +400,11 @@  discard block
 block discarded – undo
400 400
 	 * @param  string $context View or edit context.
401 401
 	 * @return string
402 402
 	 */
403
-	public function get_date_created_gmt( $context = 'view' ) {
404
-        $date = $this->get_date_created( $context );
403
+	public function get_date_created_gmt($context = 'view') {
404
+        $date = $this->get_date_created($context);
405 405
 
406
-        if ( $date ) {
407
-            $date = get_gmt_from_date( $date );
406
+        if ($date) {
407
+            $date = get_gmt_from_date($date);
408 408
         }
409 409
 		return $date;
410 410
 	}
@@ -416,8 +416,8 @@  discard block
 block discarded – undo
416 416
 	 * @param  string $context View or edit context.
417 417
 	 * @return string
418 418
 	 */
419
-	public function get_next_renewal_date( $context = 'view' ) {
420
-		return $this->get_prop( 'expiration', $context );
419
+	public function get_next_renewal_date($context = 'view') {
420
+		return $this->get_prop('expiration', $context);
421 421
 	}
422 422
 
423 423
 	/**
@@ -427,8 +427,8 @@  discard block
 block discarded – undo
427 427
 	 * @param  string $context View or edit context.
428 428
 	 * @return string
429 429
 	 */
430
-	public function get_expiration( $context = 'view' ) {
431
-		return $this->get_next_renewal_date( $context );
430
+	public function get_expiration($context = 'view') {
431
+		return $this->get_next_renewal_date($context);
432 432
 	}
433 433
 
434 434
 	/**
@@ -440,12 +440,12 @@  discard block
 block discarded – undo
440 440
 	public function get_expiration_time() {
441 441
 		$expiration = $this->get_expiration();
442 442
 
443
-		if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
444
-			return current_time( 'timestamp' );
443
+		if (empty($expiration) || '0000-00-00 00:00:00' == $expiration) {
444
+			return current_time('timestamp');
445 445
 		}
446 446
 
447
-		$expiration = strtotime( $expiration, current_time( 'timestamp' ) );
448
-		return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration;
447
+		$expiration = strtotime($expiration, current_time('timestamp'));
448
+		return $expiration < current_time('timestamp') ? current_time('timestamp') : $expiration;
449 449
 	}
450 450
 
451 451
 	/**
@@ -455,11 +455,11 @@  discard block
 block discarded – undo
455 455
 	 * @param  string $context View or edit context.
456 456
 	 * @return string
457 457
 	 */
458
-	public function get_next_renewal_date_gmt( $context = 'view' ) {
459
-        $date = $this->get_next_renewal_date( $context );
458
+	public function get_next_renewal_date_gmt($context = 'view') {
459
+        $date = $this->get_next_renewal_date($context);
460 460
 
461
-        if ( $date ) {
462
-            $date = get_gmt_from_date( $date );
461
+        if ($date) {
462
+            $date = get_gmt_from_date($date);
463 463
         }
464 464
 		return $date;
465 465
 	}
@@ -471,8 +471,8 @@  discard block
 block discarded – undo
471 471
 	 * @param  string $context View or edit context.
472 472
 	 * @return string
473 473
 	 */
474
-	public function get_trial_period( $context = 'view' ) {
475
-		return $this->get_prop( 'trial_period', $context );
474
+	public function get_trial_period($context = 'view') {
475
+		return $this->get_prop('trial_period', $context);
476 476
 	}
477 477
 
478 478
 	/**
@@ -482,8 +482,8 @@  discard block
 block discarded – undo
482 482
 	 * @param  string $context View or edit context.
483 483
 	 * @return string
484 484
 	 */
485
-	public function get_status( $context = 'view' ) {
486
-		return $this->get_prop( 'status', $context );
485
+	public function get_status($context = 'view') {
486
+		return $this->get_prop('status', $context);
487 487
 	}
488 488
 
489 489
 	/**
@@ -493,8 +493,8 @@  discard block
 block discarded – undo
493 493
 	 * @param  string $context View or edit context.
494 494
 	 * @return string
495 495
 	 */
496
-	public function get_profile_id( $context = 'view' ) {
497
-		return $this->get_prop( 'profile_id', $context );
496
+	public function get_profile_id($context = 'view') {
497
+		return $this->get_prop('profile_id', $context);
498 498
 	}
499 499
 
500 500
 	/*
@@ -509,8 +509,8 @@  discard block
 block discarded – undo
509 509
 	 * @since 1.0.19
510 510
 	 * @param  int $value The customer's id.
511 511
 	 */
512
-	public function set_customer_id( $value ) {
513
-		$this->set_prop( 'customer_id', (int) $value );
512
+	public function set_customer_id($value) {
513
+		$this->set_prop('customer_id', (int) $value);
514 514
 	}
515 515
 
516 516
 	/**
@@ -519,8 +519,8 @@  discard block
 block discarded – undo
519 519
 	 * @since 1.0.19
520 520
 	 * @param  int $value The parent invoice id.
521 521
 	 */
522
-	public function set_parent_invoice_id( $value ) {
523
-		$this->set_prop( 'parent_payment_id', (int) $value );
522
+	public function set_parent_invoice_id($value) {
523
+		$this->set_prop('parent_payment_id', (int) $value);
524 524
 	}
525 525
 
526 526
 	/**
@@ -529,8 +529,8 @@  discard block
 block discarded – undo
529 529
 	 * @since 1.0.19
530 530
 	 * @param  int $value The parent invoice id.
531 531
 	 */
532
-    public function set_parent_payment_id( $value ) {
533
-        $this->set_parent_invoice_id( $value );
532
+    public function set_parent_payment_id($value) {
533
+        $this->set_parent_invoice_id($value);
534 534
 	}
535 535
 
536 536
 	/**
@@ -539,8 +539,8 @@  discard block
 block discarded – undo
539 539
      * @since 1.0.19
540 540
 	 * @param  int $value The parent invoice id.
541 541
      */
542
-    public function set_original_payment_id( $value ) {
543
-        $this->set_parent_invoice_id( $value );
542
+    public function set_original_payment_id($value) {
543
+        $this->set_parent_invoice_id($value);
544 544
 	}
545 545
 
546 546
 	/**
@@ -549,8 +549,8 @@  discard block
 block discarded – undo
549 549
 	 * @since 1.0.19
550 550
 	 * @param  int $value The subscription product id.
551 551
 	 */
552
-	public function set_product_id( $value ) {
553
-		$this->set_prop( 'product_id', (int) $value );
552
+	public function set_product_id($value) {
553
+		$this->set_prop('product_id', (int) $value);
554 554
 	}
555 555
 
556 556
 	/**
@@ -559,8 +559,8 @@  discard block
 block discarded – undo
559 559
 	 * @since 1.0.19
560 560
 	 * @param  string $value The renewal period.
561 561
 	 */
562
-	public function set_period( $value ) {
563
-		$this->set_prop( 'period', $value );
562
+	public function set_period($value) {
563
+		$this->set_prop('period', $value);
564 564
 	}
565 565
 
566 566
 	/**
@@ -569,9 +569,9 @@  discard block
 block discarded – undo
569 569
 	 * @since 1.0.19
570 570
 	 * @param  int $value The subscription frequency.
571 571
 	 */
572
-	public function set_frequency( $value ) {
573
-		$value = empty( $value ) ? 1 : (int) $value;
574
-		$this->set_prop( 'frequency', absint( $value ) );
572
+	public function set_frequency($value) {
573
+		$value = empty($value) ? 1 : (int) $value;
574
+		$this->set_prop('frequency', absint($value));
575 575
 	}
576 576
 
577 577
 	/**
@@ -580,8 +580,8 @@  discard block
 block discarded – undo
580 580
 	 * @since 1.0.19
581 581
 	 * @param  float $value The initial subcription amount.
582 582
 	 */
583
-	public function set_initial_amount( $value ) {
584
-		$this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) );
583
+	public function set_initial_amount($value) {
584
+		$this->set_prop('initial_amount', wpinv_sanitize_amount($value));
585 585
 	}
586 586
 
587 587
 	/**
@@ -590,8 +590,8 @@  discard block
 block discarded – undo
590 590
 	 * @since 1.0.19
591 591
 	 * @param  float $value The recurring subcription amount.
592 592
 	 */
593
-	public function set_recurring_amount( $value ) {
594
-		$this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) );
593
+	public function set_recurring_amount($value) {
594
+		$this->set_prop('recurring_amount', wpinv_sanitize_amount($value));
595 595
 	}
596 596
 
597 597
 	/**
@@ -600,8 +600,8 @@  discard block
 block discarded – undo
600 600
 	 * @since 1.0.19
601 601
 	 * @param  int $value Bill times.
602 602
 	 */
603
-	public function set_bill_times( $value ) {
604
-		$this->set_prop( 'bill_times', (int) $value );
603
+	public function set_bill_times($value) {
604
+		$this->set_prop('bill_times', (int) $value);
605 605
 	}
606 606
 
607 607
 	/**
@@ -610,8 +610,8 @@  discard block
 block discarded – undo
610 610
 	 * @since 1.0.19
611 611
 	 * @param string $value Bill times.
612 612
 	 */
613
-	public function set_transaction_id( $value ) {
614
-		$this->set_prop( 'transaction_id', sanitize_text_field( $value ) );
613
+	public function set_transaction_id($value) {
614
+		$this->set_prop('transaction_id', sanitize_text_field($value));
615 615
 	}
616 616
 
617 617
 	/**
@@ -620,15 +620,15 @@  discard block
 block discarded – undo
620 620
 	 * @since 1.0.19
621 621
 	 * @param string $value strtotime compliant date.
622 622
 	 */
623
-	public function set_created( $value ) {
624
-        $date = strtotime( $value );
623
+	public function set_created($value) {
624
+        $date = strtotime($value);
625 625
 
626
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
627
-            $this->set_prop( 'created', date( 'Y-m-d H:i:s', $date ) );
626
+        if ($date && $value !== '0000-00-00 00:00:00') {
627
+            $this->set_prop('created', date('Y-m-d H:i:s', $date));
628 628
             return;
629 629
         }
630 630
 
631
-		$this->set_prop( 'created', '' );
631
+		$this->set_prop('created', '');
632 632
 
633 633
 	}
634 634
 
@@ -638,8 +638,8 @@  discard block
 block discarded – undo
638 638
 	 * @since 1.0.19
639 639
 	 * @param string $value strtotime compliant date.
640 640
 	 */
641
-	public function set_date_created( $value ) {
642
-		$this->set_created( $value );
641
+	public function set_date_created($value) {
642
+		$this->set_created($value);
643 643
     }
644 644
 
645 645
 	/**
@@ -648,15 +648,15 @@  discard block
 block discarded – undo
648 648
 	 * @since 1.0.19
649 649
 	 * @param string $value strtotime compliant date.
650 650
 	 */
651
-	public function set_next_renewal_date( $value ) {
652
-		$date = strtotime( $value );
651
+	public function set_next_renewal_date($value) {
652
+		$date = strtotime($value);
653 653
 
654
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
655
-            $this->set_prop( 'expiration', date( 'Y-m-d H:i:s', $date ) );
654
+        if ($date && $value !== '0000-00-00 00:00:00') {
655
+            $this->set_prop('expiration', date('Y-m-d H:i:s', $date));
656 656
             return;
657 657
 		}
658 658
 
659
-		$this->set_prop( 'expiration', '' );
659
+		$this->set_prop('expiration', '');
660 660
 
661 661
 	}
662 662
 
@@ -666,8 +666,8 @@  discard block
 block discarded – undo
666 666
 	 * @since 1.0.19
667 667
 	 * @param string $value strtotime compliant date.
668 668
 	 */
669
-	public function set_expiration( $value ) {
670
-		$this->set_next_renewal_date( $value );
669
+	public function set_expiration($value) {
670
+		$this->set_next_renewal_date($value);
671 671
     }
672 672
 
673 673
 	/**
@@ -676,8 +676,8 @@  discard block
 block discarded – undo
676 676
 	 * @since 1.0.19
677 677
 	 * @param string $value trial period e.g 1 year.
678 678
 	 */
679
-	public function set_trial_period( $value ) {
680
-		$this->set_prop( 'trial_period', $value );
679
+	public function set_trial_period($value) {
680
+		$this->set_prop('trial_period', $value);
681 681
 	}
682 682
 
683 683
 	/**
@@ -686,17 +686,17 @@  discard block
 block discarded – undo
686 686
 	 * @since 1.0.19
687 687
 	 * @param string $new_status    New subscription status.
688 688
 	 */
689
-	public function set_status( $new_status ) {
689
+	public function set_status($new_status) {
690 690
 
691 691
 		// Abort if this is not a valid status;
692
-		if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) {
692
+		if (!array_key_exists($new_status, getpaid_get_subscription_statuses())) {
693 693
 			return;
694 694
 		}
695 695
 
696
-		$this->set_prop( 'status', $new_status );
696
+		$this->set_prop('status', $new_status);
697 697
 
698
-		$old_status = ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $this->get_status();
699
-		if ( true === $this->object_read && $old_status !== $new_status ) {
698
+		$old_status = !empty($this->status_transition['from']) ? $this->status_transition['from'] : $this->get_status();
699
+		if (true === $this->object_read && $old_status !== $new_status) {
700 700
 			$this->status_transition = array(
701 701
 				'from'   => $old_status,
702 702
 				'to'     => $new_status,
@@ -711,8 +711,8 @@  discard block
 block discarded – undo
711 711
 	 * @since 1.0.19
712 712
 	 * @param  string $value the remote profile id.
713 713
 	 */
714
-	public function set_profile_id( $value ) {
715
-		$this->set_prop( 'profile_id', sanitize_text_field( $value ) );
714
+	public function set_profile_id($value) {
715
+		$this->set_prop('profile_id', sanitize_text_field($value));
716 716
 	}
717 717
 
718 718
 	/*
@@ -730,8 +730,8 @@  discard block
 block discarded – undo
730 730
 	 * @param string|array String or array of strings to check for.
731 731
 	 * @return bool
732 732
      */
733
-    public function has_status( $status ) {
734
-        return in_array( $this->get_status(), wpinv_clean( wpinv_parse_list( $status ) ) );
733
+    public function has_status($status) {
734
+        return in_array($this->get_status(), wpinv_clean(wpinv_parse_list($status)));
735 735
 	}
736 736
 
737 737
 	/**
@@ -741,7 +741,7 @@  discard block
 block discarded – undo
741 741
      */
742 742
     public function has_trial_period() {
743 743
 		$period = $this->get_trial_period();
744
-        return ! empty( $period );
744
+        return !empty($period);
745 745
 	}
746 746
 
747 747
 	/**
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
 	 * @return bool
751 751
 	 */
752 752
 	public function is_active() {
753
-		return $this->has_status( 'active trialling' ) && ! $this->is_expired();
753
+		return $this->has_status('active trialling') && !$this->is_expired();
754 754
 	}
755 755
 
756 756
 	/**
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
 	 * @return bool
760 760
 	 */
761 761
 	public function is_expired() {
762
-		return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'mysql' ) );
762
+		return $this->has_status('expired') || ($this->has_status('active cancelled trialling') && $this->get_expiration_time() < current_time('mysql'));
763 763
 	}
764 764
 
765 765
 	/**
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
 	 */
770 770
 	public function is_last_renewal() {
771 771
 		$max_bills = $this->get_bill_times();
772
-		return ! empty( $max_bills ) && $max_bills <= $this->get_times_billed();
772
+		return !empty($max_bills) && $max_bills <= $this->get_times_billed();
773 773
 	}
774 774
 
775 775
 	/*
@@ -784,11 +784,11 @@  discard block
 block discarded – undo
784 784
 	/**
785 785
 	 * Backwards compatibilty.
786 786
 	 */
787
-	public function create( $data = array() ) {
787
+	public function create($data = array()) {
788 788
 
789 789
 		// Set the properties.
790
-		if ( is_array( $data ) ) {
791
-			$this->set_props( $data );
790
+		if (is_array($data)) {
791
+			$this->set_props($data);
792 792
 		}
793 793
 
794 794
 		// Save the item.
@@ -799,8 +799,8 @@  discard block
 block discarded – undo
799 799
 	/**
800 800
 	 * Backwards compatibilty.
801 801
 	 */
802
-	public function update( $args = array() ) {
803
-		return $this->create( $args );
802
+	public function update($args = array()) {
803
+		return $this->create($args);
804 804
 	}
805 805
 
806 806
     /**
@@ -809,12 +809,12 @@  discard block
 block discarded – undo
809 809
      * @since  1.0.0
810 810
      * @return WP_Post[]
811 811
      */
812
-    public function get_child_payments( $hide_pending = true ) {
812
+    public function get_child_payments($hide_pending = true) {
813 813
 
814
-		$statuses = array( 'publish', 'wpi-processing', 'wpi-renewal' );
814
+		$statuses = array('publish', 'wpi-processing', 'wpi-renewal');
815 815
 
816
-		if ( ! $hide_pending ) {
817
-			$statuses = array_keys( wpinv_get_invoice_statuses() );
816
+		if (!$hide_pending) {
817
+			$statuses = array_keys(wpinv_get_invoice_statuses());
818 818
 		}
819 819
 
820 820
         return get_posts(
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
      * @return int
837 837
      */
838 838
     public function get_total_payments() {
839
-		return getpaid_count_subscription_invoices( $this->get_parent_invoice_id(), $this->get_id() );
839
+		return getpaid_count_subscription_invoices($this->get_parent_invoice_id(), $this->get_id());
840 840
     }
841 841
 
842 842
     /**
@@ -848,7 +848,7 @@  discard block
 block discarded – undo
848 848
     public function get_times_billed() {
849 849
         $times_billed = $this->get_total_payments();
850 850
 
851
-        if ( (float) $this->get_initial_amount() == 0 && $times_billed > 0 ) {
851
+        if ((float) $this->get_initial_amount() == 0 && $times_billed > 0) {
852 852
             $times_billed--;
853 853
         }
854 854
 
@@ -863,49 +863,49 @@  discard block
 block discarded – undo
863 863
 	 * @param  WPInv_Invoice $invoice If adding an existing invoice.
864 864
      * @return bool
865 865
      */
866
-    public function add_payment( $args = array(), $invoice = false ) {
866
+    public function add_payment($args = array(), $invoice = false) {
867 867
 
868 868
 		// Process each payment once.
869
-        if ( ! empty( $args['transaction_id'] ) && $this->payment_exists( $args['transaction_id'] ) ) {
869
+        if (!empty($args['transaction_id']) && $this->payment_exists($args['transaction_id'])) {
870 870
             return false;
871 871
         }
872 872
 
873 873
 		// Are we creating a new invoice?
874
-		if ( empty( $invoice ) ) {
874
+		if (empty($invoice)) {
875 875
 			$invoice = $this->create_payment();
876 876
 
877
-			if ( empty( $invoice ) ) {
877
+			if (empty($invoice)) {
878 878
 				return false;
879 879
 			}
880 880
 
881 881
 		}
882 882
 
883
-		$invoice->set_status( 'wpi-renewal' );
883
+		$invoice->set_status('wpi-renewal');
884 884
 
885 885
 		// Maybe set a transaction id.
886
-		if ( ! empty( $args['transaction_id'] ) ) {
887
-			$invoice->set_transaction_id( $args['transaction_id'] );
886
+		if (!empty($args['transaction_id'])) {
887
+			$invoice->set_transaction_id($args['transaction_id']);
888 888
 		}
889 889
 
890 890
 		// Set the completed date.
891
-		$invoice->set_completed_date( current_time( 'mysql' ) );
891
+		$invoice->set_completed_date(current_time('mysql'));
892 892
 
893 893
 		// And the gateway.
894
-		if ( ! empty( $args['gateway'] ) ) {
895
-			$invoice->set_gateway( $args['gateway'] );
894
+		if (!empty($args['gateway'])) {
895
+			$invoice->set_gateway($args['gateway']);
896 896
 		}
897 897
 
898 898
 		$invoice->save();
899 899
 
900
-		if ( ! $invoice->exists() ) {
900
+		if (!$invoice->exists()) {
901 901
 			return false;
902 902
 		}
903 903
 
904
-		do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this );
905
-		do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this );
906
-        do_action( 'wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id() );
904
+		do_action('getpaid_after_create_subscription_renewal_invoice', $invoice, $this);
905
+		do_action('wpinv_recurring_add_subscription_payment', $invoice, $this);
906
+        do_action('wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id());
907 907
 
908
-        update_post_meta( $invoice->get_id(), '_wpinv_subscription_id', $this->id );
908
+        update_post_meta($invoice->get_id(), '_wpinv_subscription_id', $this->id);
909 909
 
910 910
         return $invoice->get_id();
911 911
 	}
@@ -920,41 +920,41 @@  discard block
 block discarded – undo
920 920
 
921 921
 		$parent_invoice = $this->get_parent_payment();
922 922
 
923
-		if ( ! $parent_invoice->exists() ) {
923
+		if (!$parent_invoice->exists()) {
924 924
 			return false;
925 925
 		}
926 926
 
927 927
 		// Duplicate the parent invoice.
928
-		$invoice = getpaid_duplicate_invoice( $parent_invoice );
929
-		$invoice->set_parent_id( $parent_invoice->get_id() );
930
-		$invoice->set_subscription_id( $this->get_id() );
931
-		$invoice->set_remote_subscription_id( $this->get_profile_id() );
928
+		$invoice = getpaid_duplicate_invoice($parent_invoice);
929
+		$invoice->set_parent_id($parent_invoice->get_id());
930
+		$invoice->set_subscription_id($this->get_id());
931
+		$invoice->set_remote_subscription_id($this->get_profile_id());
932 932
 
933 933
 		// Set invoice items.
934
-		$subscription_group = getpaid_get_invoice_subscription_group( $parent_invoice->get_id(), $this->get_id() );
935
-		$allowed_items      = empty( $subscription_group ) ? array( $this->get_product_id() ) : array_keys( $subscription_group['items'] );
934
+		$subscription_group = getpaid_get_invoice_subscription_group($parent_invoice->get_id(), $this->get_id());
935
+		$allowed_items      = empty($subscription_group) ? array($this->get_product_id()) : array_keys($subscription_group['items']);
936 936
 		$invoice_items      = array();
937 937
 
938
-		foreach ( $invoice->get_items() as $item ) {
939
-			if ( in_array( $item->get_id(), $allowed_items ) ) {
938
+		foreach ($invoice->get_items() as $item) {
939
+			if (in_array($item->get_id(), $allowed_items)) {
940 940
 				$invoice_items[] = $item;
941 941
 			}
942 942
 		}
943 943
 
944
-		$invoice->set_items( $invoice_items );
944
+		$invoice->set_items($invoice_items);
945 945
 
946
-		if ( ! empty( $subscription_group['fees'] ) ) {
947
-			$invoice->set_fees( $subscription_group['fees'] );
946
+		if (!empty($subscription_group['fees'])) {
947
+			$invoice->set_fees($subscription_group['fees']);
948 948
 		}
949 949
 
950 950
 		// Maybe recalculate discount (Pre-GetPaid Fix).
951
-		$discount = new WPInv_Discount( $invoice->get_discount_code() );
952
-		if ( $discount->exists() && $discount->is_recurring() && 0 == $invoice->get_total_discount() ) {
953
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
951
+		$discount = new WPInv_Discount($invoice->get_discount_code());
952
+		if ($discount->exists() && $discount->is_recurring() && 0 == $invoice->get_total_discount()) {
953
+			$invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
954 954
 		}
955 955
 
956 956
 		$invoice->recalculate_total();
957
-		$invoice->set_status( 'wpi-pending' );
957
+		$invoice->set_status('wpi-pending');
958 958
 		$invoice->save();
959 959
 
960 960
 		return $invoice->exists() ? $invoice : false;
@@ -969,20 +969,20 @@  discard block
 block discarded – undo
969 969
 	public function renew() {
970 970
 
971 971
 		// Complete subscription if applicable
972
-		if ( $this->is_last_renewal() ) {
972
+		if ($this->is_last_renewal()) {
973 973
 			return $this->complete();
974 974
 		}
975 975
 
976 976
 		// Calculate new expiration
977 977
 		$frequency      = $this->get_frequency();
978 978
 		$period         = $this->get_period();
979
-		$new_expiration = strtotime( "+ $frequency $period", $this->get_expiration_time() );
979
+		$new_expiration = strtotime("+ $frequency $period", $this->get_expiration_time());
980 980
 
981
-		$this->set_expiration( date( 'Y-m-d H:i:s',$new_expiration ) );
982
-		$this->set_status( 'active' );
981
+		$this->set_expiration(date('Y-m-d H:i:s', $new_expiration));
982
+		$this->set_status('active');
983 983
 		$this->save();
984 984
 
985
-		do_action( 'getpaid_subscription_renewed', $this );
985
+		do_action('getpaid_subscription_renewed', $this);
986 986
 
987 987
 		return $this->get_id();
988 988
 	}
@@ -998,11 +998,11 @@  discard block
 block discarded – undo
998 998
 	public function complete() {
999 999
 
1000 1000
 		// Only mark a subscription as complete if it's not already cancelled.
1001
-		if ( $this->has_status( 'cancelled' ) ) {
1001
+		if ($this->has_status('cancelled')) {
1002 1002
 			return false;
1003 1003
 		}
1004 1004
 
1005
-		$this->set_status( 'completed' );
1005
+		$this->set_status('completed');
1006 1006
 		return $this->save();
1007 1007
 
1008 1008
 	}
@@ -1014,14 +1014,14 @@  discard block
 block discarded – undo
1014 1014
 	 * @param  bool $check_expiration
1015 1015
 	 * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future.
1016 1016
 	 */
1017
-	public function expire( $check_expiration = false ) {
1017
+	public function expire($check_expiration = false) {
1018 1018
 
1019
-		if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) {
1019
+		if ($check_expiration && $this->get_expiration_time() > current_time('timestamp')) {
1020 1020
 			// Do not mark as expired since real expiration date is in the future
1021 1021
 			return false;
1022 1022
 		}
1023 1023
 
1024
-		$this->set_status( 'expired' );
1024
+		$this->set_status('expired');
1025 1025
 		return $this->save();
1026 1026
 
1027 1027
 	}
@@ -1033,7 +1033,7 @@  discard block
 block discarded – undo
1033 1033
 	 * @return int Subscription id.
1034 1034
 	 */
1035 1035
 	public function failing() {
1036
-		$this->set_status( 'failing' );
1036
+		$this->set_status('failing');
1037 1037
 		return $this->save();
1038 1038
 	}
1039 1039
 
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
      * @return int Subscription id.
1045 1045
      */
1046 1046
     public function cancel() {
1047
-		$this->set_status( 'cancelled' );
1047
+		$this->set_status('cancelled');
1048 1048
 		return $this->save();
1049 1049
     }
1050 1050
 
@@ -1055,7 +1055,7 @@  discard block
 block discarded – undo
1055 1055
 	 * @return bool
1056 1056
 	 */
1057 1057
 	public function can_cancel() {
1058
-		return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this );
1058
+		return apply_filters('wpinv_subscription_can_cancel', $this->has_status($this->get_cancellable_statuses()), $this);
1059 1059
 	}
1060 1060
 
1061 1061
     /**
@@ -1066,7 +1066,7 @@  discard block
 block discarded – undo
1066 1066
      * @return      array
1067 1067
      */
1068 1068
     public function get_cancellable_statuses() {
1069
-        return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) );
1069
+        return apply_filters('wpinv_recurring_cancellable_statuses', array('active', 'trialling', 'failing'));
1070 1070
     }
1071 1071
 
1072 1072
 	/**
@@ -1076,8 +1076,8 @@  discard block
 block discarded – undo
1076 1076
 	 * @return string
1077 1077
 	 */
1078 1078
 	public function get_cancel_url() {
1079
-		$url = getpaid_get_authenticated_action_url( 'subscription_cancel', $this->get_view_url() );
1080
-		return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
1079
+		$url = getpaid_get_authenticated_action_url('subscription_cancel', $this->get_view_url());
1080
+		return apply_filters('wpinv_subscription_cancel_url', $url, $this);
1081 1081
 	}
1082 1082
 
1083 1083
 	/**
@@ -1088,10 +1088,10 @@  discard block
 block discarded – undo
1088 1088
 	 */
1089 1089
 	public function get_view_url() {
1090 1090
 
1091
-		$url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) );
1092
-		$url = add_query_arg( 'subscription', $this->get_id(), $url );
1091
+		$url = getpaid_get_tab_url('gp-subscriptions', get_permalink((int) wpinv_get_option('invoice_subscription_page')));
1092
+		$url = add_query_arg('subscription', $this->get_id(), $url);
1093 1093
 
1094
-		return apply_filters( 'getpaid_get_subscription_view_url', $url, $this );
1094
+		return apply_filters('getpaid_get_subscription_view_url', $url, $this);
1095 1095
 	}
1096 1096
 
1097 1097
 	/**
@@ -1104,7 +1104,7 @@  discard block
 block discarded – undo
1104 1104
 	 * @return bool
1105 1105
 	 */
1106 1106
 	public function can_renew() {
1107
-		return apply_filters( 'wpinv_subscription_can_renew', true, $this );
1107
+		return apply_filters('wpinv_subscription_can_renew', true, $this);
1108 1108
 	}
1109 1109
 
1110 1110
 	/**
@@ -1114,8 +1114,8 @@  discard block
 block discarded – undo
1114 1114
 	 * @return string
1115 1115
 	 */
1116 1116
 	public function get_renew_url() {
1117
-		$url = wp_nonce_url( add_query_arg( array( 'getpaid-action' => 'renew_subscription', 'sub_id' => $this->get_id ) ), 'getpaid-nonce' );
1118
-		return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
1117
+		$url = wp_nonce_url(add_query_arg(array('getpaid-action' => 'renew_subscription', 'sub_id' => $this->get_id)), 'getpaid-nonce');
1118
+		return apply_filters('wpinv_subscription_renew_url', $url, $this);
1119 1119
 	}
1120 1120
 
1121 1121
 	/**
@@ -1125,7 +1125,7 @@  discard block
 block discarded – undo
1125 1125
 	 * @return bool
1126 1126
 	 */
1127 1127
 	public function can_update() {
1128
-		return apply_filters( 'wpinv_subscription_can_update', false, $this );
1128
+		return apply_filters('wpinv_subscription_can_update', false, $this);
1129 1129
 	}
1130 1130
 
1131 1131
 	/**
@@ -1135,8 +1135,8 @@  discard block
 block discarded – undo
1135 1135
 	 * @return string
1136 1136
 	 */
1137 1137
 	public function get_update_url() {
1138
-		$url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->get_id() ) );
1139
-		return apply_filters( 'wpinv_subscription_update_url', $url, $this );
1138
+		$url = add_query_arg(array('action' => 'update', 'subscription_id' => $this->get_id()));
1139
+		return apply_filters('wpinv_subscription_update_url', $url, $this);
1140 1140
 	}
1141 1141
 
1142 1142
 	/**
@@ -1146,7 +1146,7 @@  discard block
 block discarded – undo
1146 1146
 	 * @return string
1147 1147
 	 */
1148 1148
 	public function get_status_label() {
1149
-		return getpaid_get_subscription_status_label( $this->get_status() );
1149
+		return getpaid_get_subscription_status_label($this->get_status());
1150 1150
 	}
1151 1151
 
1152 1152
 	/**
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
 	 */
1158 1158
 	public function get_status_class() {
1159 1159
 		$statuses = getpaid_get_subscription_status_classes();
1160
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark';
1160
+		return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'badge-dark';
1161 1161
 	}
1162 1162
 
1163 1163
     /**
@@ -1168,9 +1168,9 @@  discard block
 block discarded – undo
1168 1168
      */
1169 1169
     public function get_status_label_html() {
1170 1170
 
1171
-		$status_label = sanitize_text_field( $this->get_status_label() );
1172
-		$class        = esc_attr( $this->get_status_class() );
1173
-		$status       = sanitize_html_class( $this->get_status() );
1171
+		$status_label = sanitize_text_field($this->get_status_label());
1172
+		$class        = esc_attr($this->get_status_class());
1173
+		$status       = sanitize_html_class($this->get_status());
1174 1174
 
1175 1175
 		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
1176 1176
     }
@@ -1182,9 +1182,9 @@  discard block
 block discarded – undo
1182 1182
      * @param  string $txn_id The transaction ID from the merchant processor
1183 1183
      * @return bool
1184 1184
      */
1185
-    public function payment_exists( $txn_id = '' ) {
1186
-		$invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' );
1187
-        return ! empty( $invoice_id );
1185
+    public function payment_exists($txn_id = '') {
1186
+		$invoice_id = WPInv_Invoice::get_invoice_id_by_field($txn_id, 'transaction_id');
1187
+        return !empty($invoice_id);
1188 1188
 	}
1189 1189
 
1190 1190
 	/**
@@ -1196,35 +1196,35 @@  discard block
 block discarded – undo
1196 1196
 		// Reset status transition variable.
1197 1197
 		$this->status_transition = false;
1198 1198
 
1199
-		if ( $status_transition ) {
1199
+		if ($status_transition) {
1200 1200
 			try {
1201 1201
 
1202 1202
 				// Fire a hook for the status change.
1203
-				do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
1204
-				do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition );
1203
+				do_action('wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition);
1204
+				do_action('getpaid_subscription_' . $status_transition['to'], $this, $status_transition);
1205 1205
 
1206
-				if ( ! empty( $status_transition['from'] ) ) {
1206
+				if (!empty($status_transition['from'])) {
1207 1207
 
1208 1208
 					/* translators: 1: old subscription status 2: new subscription status */
1209
-					$transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1209
+					$transition_note = sprintf(__('Subscription status changed from %1$s to %2$s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['from']), getpaid_get_subscription_status_label($status_transition['to']));
1210 1210
 
1211 1211
 					// Note the transition occurred.
1212
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1212
+					$this->get_parent_payment()->add_note($transition_note, false, false, true);
1213 1213
 
1214 1214
 					// Fire another hook.
1215
-					do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
1216
-					do_action( 'getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to'] );
1215
+					do_action('getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this);
1216
+					do_action('getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to']);
1217 1217
 
1218 1218
 				} else {
1219 1219
 					/* translators: %s: new invoice status */
1220
-					$transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1220
+					$transition_note = sprintf(__('Subscription status set to %s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['to']));
1221 1221
 
1222 1222
 					// Note the transition occurred.
1223
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1223
+					$this->get_parent_payment()->add_note($transition_note, false, false, true);
1224 1224
 
1225 1225
 				}
1226
-			} catch ( Exception $e ) {
1227
-				$this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
1226
+			} catch (Exception $e) {
1227
+				$this->get_parent_payment()->add_note(__('Error during subscription status transition.', 'invoicing') . ' ' . $e->getMessage());
1228 1228
 			}
1229 1229
 		}
1230 1230
 
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
 	 */
1251 1251
 	public function activate() {
1252 1252
 		$status = 'trialling' == $this->get_status() ? 'trialling' : 'active';
1253
-		$this->set_status( $status );
1253
+		$this->set_status($status);
1254 1254
 		return $this->save();
1255 1255
 	}
1256 1256
 
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-paypal-gateway-ipn-handler.php 2 patches
Indentation   +390 added lines, -390 removed lines patch added patch discarded remove patch
@@ -12,474 +12,474 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Paypal_Gateway_IPN_Handler {
14 14
 
15
-	/**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
20
-	protected $id = 'paypal';
21
-
22
-	/**
23
-	 * Payment method object.
24
-	 *
25
-	 * @var GetPaid_Paypal_Gateway
26
-	 */
27
-	protected $gateway;
28
-
29
-	/**
30
-	 * Class constructor.
31
-	 *
32
-	 * @param GetPaid_Paypal_Gateway $gateway
33
-	 */
34
-	public function __construct( $gateway ) {
35
-		$this->gateway = $gateway;
36
-		$this->verify_ipn();
37
-	}
38
-
39
-	/**
40
-	 * Processes ipns and marks payments as complete.
41
-	 *
42
-	 * @return void
43
-	 */
44
-	public function verify_ipn() {
45
-
46
-		wpinv_error_log( 'GetPaid PayPal IPN Handler', false );
47
-
48
-		// Validate the IPN.
49
-		if ( empty( $_POST ) || ! $this->validate_ipn() ) {
50
-			wp_die( 'PayPal IPN Request Failure', 500 );
51
-		}
52
-
53
-		// Process the IPN.
54
-		$posted  = wp_unslash( $_POST );
55
-		$invoice = $this->get_ipn_invoice( $posted );
56
-
57
-		// Abort if it was not paid by our gateway.
58
-		if ( $this->id != $invoice->get_gateway() ) {
59
-			wpinv_error_log( 'Aborting, Invoice was not paid via PayPal', false );
60
-			wp_die( 'Invoice not paid via PayPal', 200 );
61
-		}
62
-
63
-		$posted['payment_status'] = isset( $posted['payment_status'] ) ? sanitize_key( strtolower( $posted['payment_status'] ) ) : '';
64
-		$posted['txn_type']       = sanitize_key( strtolower( $posted['txn_type'] ) );
65
-
66
-		wpinv_error_log( 'Payment status:' . $posted['payment_status'], false );
67
-		wpinv_error_log( 'IPN Type:' . $posted['txn_type'], false );
68
-
69
-		if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) {
70
-			call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted );
71
-			wpinv_error_log( 'Done processing IPN', false );
72
-			wp_die( 'Processed', 200 );
73
-		}
74
-
75
-		wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'], false );
76
-		wp_die( 'Unsupported IPN type', 200 );
77
-
78
-	}
79
-
80
-	/**
81
-	 * Retrieves IPN Invoice.
82
-	 *
83
-	 * @param array $posted
84
-	 * @return WPInv_Invoice
85
-	 */
86
-	protected function get_ipn_invoice( $posted ) {
87
-
88
-		wpinv_error_log( 'Retrieving PayPal IPN Response Invoice', false );
89
-
90
-		if ( ! empty( $posted['custom'] ) ) {
91
-			$invoice = new WPInv_Invoice( $posted['custom'] );
92
-
93
-			if ( $invoice->exists() ) {
94
-				wpinv_error_log( 'Found invoice #' . $invoice->get_number(), false );
95
-				return $invoice;
96
-			}
97
-
98
-		}
99
-
100
-		wpinv_error_log( 'Could not retrieve the associated invoice.', false );
101
-		wp_die( 'Could not retrieve the associated invoice.', 200 );
102
-	}
103
-
104
-	/**
105
-	 * Check PayPal IPN validity.
106
-	 */
107
-	protected function validate_ipn() {
108
-
109
-		wpinv_error_log( 'Validating PayPal IPN response', false );
110
-
111
-		// Retrieve the associated invoice.
112
-		$posted  = wp_unslash( $_POST );
113
-		$invoice = $this->get_ipn_invoice( $posted );
114
-
115
-		if ( $this->gateway->is_sandbox( $invoice ) ) {
116
-			wpinv_error_log( $posted, 'Invoice was processed in sandbox hence logging the posted data', false );
117
-		}
118
-
119
-		// Validate the IPN.
120
-		$posted['cmd'] = '_notify-validate';
121
-
122
-		// Send back post vars to paypal.
123
-		$params = array(
124
-			'body'        => $posted,
125
-			'timeout'     => 60,
126
-			'httpversion' => '1.1',
127
-			'compress'    => false,
128
-			'decompress'  => false,
129
-			'user-agent'  => 'GetPaid/' . WPINV_VERSION,
130
-		);
131
-
132
-		// Post back to get a response.
133
-		$response = wp_safe_remote_post( $this->gateway->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params );
134
-
135
-		// Check to see if the request was valid.
136
-		if ( ! is_wp_error( $response ) && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {
137
-			wpinv_error_log( 'Received valid response from PayPal IPN: ' . $response['body'], false );
138
-			return true;
139
-		}
140
-
141
-		if ( is_wp_error( $response ) ) {
142
-			wpinv_error_log( $response->get_error_message(), 'Received invalid response from PayPal IPN' );
143
-			return false;
144
-		}
15
+    /**
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20
+    protected $id = 'paypal';
21
+
22
+    /**
23
+     * Payment method object.
24
+     *
25
+     * @var GetPaid_Paypal_Gateway
26
+     */
27
+    protected $gateway;
28
+
29
+    /**
30
+     * Class constructor.
31
+     *
32
+     * @param GetPaid_Paypal_Gateway $gateway
33
+     */
34
+    public function __construct( $gateway ) {
35
+        $this->gateway = $gateway;
36
+        $this->verify_ipn();
37
+    }
38
+
39
+    /**
40
+     * Processes ipns and marks payments as complete.
41
+     *
42
+     * @return void
43
+     */
44
+    public function verify_ipn() {
45
+
46
+        wpinv_error_log( 'GetPaid PayPal IPN Handler', false );
47
+
48
+        // Validate the IPN.
49
+        if ( empty( $_POST ) || ! $this->validate_ipn() ) {
50
+            wp_die( 'PayPal IPN Request Failure', 500 );
51
+        }
52
+
53
+        // Process the IPN.
54
+        $posted  = wp_unslash( $_POST );
55
+        $invoice = $this->get_ipn_invoice( $posted );
56
+
57
+        // Abort if it was not paid by our gateway.
58
+        if ( $this->id != $invoice->get_gateway() ) {
59
+            wpinv_error_log( 'Aborting, Invoice was not paid via PayPal', false );
60
+            wp_die( 'Invoice not paid via PayPal', 200 );
61
+        }
62
+
63
+        $posted['payment_status'] = isset( $posted['payment_status'] ) ? sanitize_key( strtolower( $posted['payment_status'] ) ) : '';
64
+        $posted['txn_type']       = sanitize_key( strtolower( $posted['txn_type'] ) );
65
+
66
+        wpinv_error_log( 'Payment status:' . $posted['payment_status'], false );
67
+        wpinv_error_log( 'IPN Type:' . $posted['txn_type'], false );
68
+
69
+        if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) {
70
+            call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted );
71
+            wpinv_error_log( 'Done processing IPN', false );
72
+            wp_die( 'Processed', 200 );
73
+        }
74
+
75
+        wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'], false );
76
+        wp_die( 'Unsupported IPN type', 200 );
77
+
78
+    }
79
+
80
+    /**
81
+     * Retrieves IPN Invoice.
82
+     *
83
+     * @param array $posted
84
+     * @return WPInv_Invoice
85
+     */
86
+    protected function get_ipn_invoice( $posted ) {
87
+
88
+        wpinv_error_log( 'Retrieving PayPal IPN Response Invoice', false );
89
+
90
+        if ( ! empty( $posted['custom'] ) ) {
91
+            $invoice = new WPInv_Invoice( $posted['custom'] );
92
+
93
+            if ( $invoice->exists() ) {
94
+                wpinv_error_log( 'Found invoice #' . $invoice->get_number(), false );
95
+                return $invoice;
96
+            }
97
+
98
+        }
99
+
100
+        wpinv_error_log( 'Could not retrieve the associated invoice.', false );
101
+        wp_die( 'Could not retrieve the associated invoice.', 200 );
102
+    }
103
+
104
+    /**
105
+     * Check PayPal IPN validity.
106
+     */
107
+    protected function validate_ipn() {
108
+
109
+        wpinv_error_log( 'Validating PayPal IPN response', false );
110
+
111
+        // Retrieve the associated invoice.
112
+        $posted  = wp_unslash( $_POST );
113
+        $invoice = $this->get_ipn_invoice( $posted );
114
+
115
+        if ( $this->gateway->is_sandbox( $invoice ) ) {
116
+            wpinv_error_log( $posted, 'Invoice was processed in sandbox hence logging the posted data', false );
117
+        }
118
+
119
+        // Validate the IPN.
120
+        $posted['cmd'] = '_notify-validate';
121
+
122
+        // Send back post vars to paypal.
123
+        $params = array(
124
+            'body'        => $posted,
125
+            'timeout'     => 60,
126
+            'httpversion' => '1.1',
127
+            'compress'    => false,
128
+            'decompress'  => false,
129
+            'user-agent'  => 'GetPaid/' . WPINV_VERSION,
130
+        );
131
+
132
+        // Post back to get a response.
133
+        $response = wp_safe_remote_post( $this->gateway->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params );
134
+
135
+        // Check to see if the request was valid.
136
+        if ( ! is_wp_error( $response ) && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {
137
+            wpinv_error_log( 'Received valid response from PayPal IPN: ' . $response['body'], false );
138
+            return true;
139
+        }
140
+
141
+        if ( is_wp_error( $response ) ) {
142
+            wpinv_error_log( $response->get_error_message(), 'Received invalid response from PayPal IPN' );
143
+            return false;
144
+        }
145 145
 
146
-		wpinv_error_log( $response['body'], 'Received invalid response from PayPal IPN' );
147
-		return false;
148
-
149
-	}
146
+        wpinv_error_log( $response['body'], 'Received invalid response from PayPal IPN' );
147
+        return false;
148
+
149
+    }
150 150
 
151
-	/**
152
-	 * Check currency from IPN matches the invoice.
153
-	 *
154
-	 * @param WPInv_Invoice $invoice          Invoice object.
155
-	 * @param string   $currency currency to validate.
156
-	 */
157
-	protected function validate_ipn_currency( $invoice, $currency ) {
151
+    /**
152
+     * Check currency from IPN matches the invoice.
153
+     *
154
+     * @param WPInv_Invoice $invoice          Invoice object.
155
+     * @param string   $currency currency to validate.
156
+     */
157
+    protected function validate_ipn_currency( $invoice, $currency ) {
158 158
 
159
-		if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) {
159
+        if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) {
160 160
 
161
-			/* translators: %s: currency code. */
162
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) );
161
+            /* translators: %s: currency code. */
162
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) );
163 163
 
164
-			wpinv_error_log( "Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true );
165
-		}
164
+            wpinv_error_log( "Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true );
165
+        }
166 166
 
167
-		wpinv_error_log( $currency, 'Validated IPN Currency', false );
168
-	}
167
+        wpinv_error_log( $currency, 'Validated IPN Currency', false );
168
+    }
169 169
 
170
-	/**
171
-	 * Check payment amount from IPN matches the invoice.
172
-	 *
173
-	 * @param WPInv_Invoice $invoice          Invoice object.
174
-	 * @param float   $amount amount to validate.
175
-	 */
176
-	protected function validate_ipn_amount( $invoice, $amount ) {
177
-		if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
170
+    /**
171
+     * Check payment amount from IPN matches the invoice.
172
+     *
173
+     * @param WPInv_Invoice $invoice          Invoice object.
174
+     * @param float   $amount amount to validate.
175
+     */
176
+    protected function validate_ipn_amount( $invoice, $amount ) {
177
+        if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
178 178
 
179
-			/* translators: %s: Amount. */
180
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) );
179
+            /* translators: %s: Amount. */
180
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) );
181 181
 
182
-			wpinv_error_log( "Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true );
183
-		}
182
+            wpinv_error_log( "Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true );
183
+        }
184 184
 
185
-		wpinv_error_log( $amount, 'Validated IPN Amount', false );
186
-	}
185
+        wpinv_error_log( $amount, 'Validated IPN Amount', false );
186
+    }
187 187
 
188
-	/**
189
-	 * Verify receiver email from PayPal.
190
-	 *
191
-	 * @param WPInv_Invoice $invoice          Invoice object.
192
-	 * @param string   $receiver_email Email to validate.
193
-	 */
194
-	protected function validate_ipn_receiver_email( $invoice, $receiver_email ) {
195
-		$paypal_email = wpinv_get_option( 'paypal_email' );
188
+    /**
189
+     * Verify receiver email from PayPal.
190
+     *
191
+     * @param WPInv_Invoice $invoice          Invoice object.
192
+     * @param string   $receiver_email Email to validate.
193
+     */
194
+    protected function validate_ipn_receiver_email( $invoice, $receiver_email ) {
195
+        $paypal_email = wpinv_get_option( 'paypal_email' );
196 196
 
197
-		if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) {
198
-			wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" );
197
+        if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) {
198
+            wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" );
199 199
 
200
-			/* translators: %s: email address . */
201
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) );
200
+            /* translators: %s: email address . */
201
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) );
202 202
 
203
-			return wpinv_error_log( "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true );
204
-		}
203
+            return wpinv_error_log( "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true );
204
+        }
205 205
 
206
-		wpinv_error_log( 'Validated PayPal Email', false );
207
-	}
206
+        wpinv_error_log( 'Validated PayPal Email', false );
207
+    }
208 208
 
209
-	/**
210
-	 * Handles one time payments.
211
-	 *
212
-	 * @param WPInv_Invoice $invoice  Invoice object.
213
-	 * @param array    $posted Posted data.
214
-	 */
215
-	protected function ipn_txn_web_accept( $invoice, $posted ) {
209
+    /**
210
+     * Handles one time payments.
211
+     *
212
+     * @param WPInv_Invoice $invoice  Invoice object.
213
+     * @param array    $posted Posted data.
214
+     */
215
+    protected function ipn_txn_web_accept( $invoice, $posted ) {
216 216
 
217
-		// Collect payment details
218
-		$payment_status = strtolower( $posted['payment_status'] );
219
-		$business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
217
+        // Collect payment details
218
+        $payment_status = strtolower( $posted['payment_status'] );
219
+        $business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
220 220
 
221
-		$this->validate_ipn_receiver_email( $invoice, $business_email );
222
-		$this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
221
+        $this->validate_ipn_receiver_email( $invoice, $business_email );
222
+        $this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
223 223
 
224
-		// Update the transaction id.
225
-		if ( ! empty( $posted['txn_id'] ) ) {
226
-			$invoice->set_transaction_id( wpinv_clean( $posted['txn_id'] ) );
227
-			$invoice->save();
228
-		}
224
+        // Update the transaction id.
225
+        if ( ! empty( $posted['txn_id'] ) ) {
226
+            $invoice->set_transaction_id( wpinv_clean( $posted['txn_id'] ) );
227
+            $invoice->save();
228
+        }
229 229
 
230
-		$invoice->add_system_note( __( 'Processing invoice IPN', 'invoicing' ) );
230
+        $invoice->add_system_note( __( 'Processing invoice IPN', 'invoicing' ) );
231 231
 
232
-		// Process a refund.
233
-		if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
232
+        // Process a refund.
233
+        if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
234 234
 
235
-			update_post_meta( $invoice->get_id(), 'refunded_remotely', 1 );
235
+            update_post_meta( $invoice->get_id(), 'refunded_remotely', 1 );
236 236
 
237
-			if ( ! $invoice->is_refunded() ) {
238
-				$invoice->update_status( 'wpi-refunded', $posted['reason_code'] );
239
-			}
237
+            if ( ! $invoice->is_refunded() ) {
238
+                $invoice->update_status( 'wpi-refunded', $posted['reason_code'] );
239
+            }
240 240
 
241
-			return wpinv_error_log( $posted['reason_code'], false );
242
-		}
241
+            return wpinv_error_log( $posted['reason_code'], false );
242
+        }
243 243
 
244
-		// Process payments.
245
-		if ( $payment_status == 'completed' ) {
244
+        // Process payments.
245
+        if ( $payment_status == 'completed' ) {
246 246
 
247
-			if ( $invoice->is_paid() && 'wpi_processing' != $invoice->get_status() ) {
248
-				return wpinv_error_log( 'Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false );
249
-			}
247
+            if ( $invoice->is_paid() && 'wpi_processing' != $invoice->get_status() ) {
248
+                return wpinv_error_log( 'Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false );
249
+            }
250 250
 
251
-			$this->validate_ipn_amount( $invoice, $posted['mc_gross'] );
251
+            $this->validate_ipn_amount( $invoice, $posted['mc_gross'] );
252 252
 
253
-			$note = '';
253
+            $note = '';
254 254
 
255
-			if ( ! empty( $posted['mc_fee'] ) ) {
256
-				$note = sprintf( __( 'PayPal Transaction Fee %.', 'invoicing' ), sanitize_text_field( $posted['mc_fee'] ) );
257
-			}
255
+            if ( ! empty( $posted['mc_fee'] ) ) {
256
+                $note = sprintf( __( 'PayPal Transaction Fee %.', 'invoicing' ), sanitize_text_field( $posted['mc_fee'] ) );
257
+            }
258 258
 
259
-			if ( ! empty( $posted['payer_status'] ) ) {
260
-				$note = ' ' . sprintf( __( 'Buyer status %.', 'invoicing' ), sanitize_text_field( $posted['payer_status'] ) );
261
-			}
259
+            if ( ! empty( $posted['payer_status'] ) ) {
260
+                $note = ' ' . sprintf( __( 'Buyer status %.', 'invoicing' ), sanitize_text_field( $posted['payer_status'] ) );
261
+            }
262 262
 
263
-			$invoice->mark_paid( ( ! empty( $posted['txn_id'] ) ? sanitize_text_field( $posted['txn_id'] ) : '' ), trim( $note ) );
264
-			return wpinv_error_log( 'Invoice marked as paid.', false );
263
+            $invoice->mark_paid( ( ! empty( $posted['txn_id'] ) ? sanitize_text_field( $posted['txn_id'] ) : '' ), trim( $note ) );
264
+            return wpinv_error_log( 'Invoice marked as paid.', false );
265 265
 
266
-		}
266
+        }
267 267
 
268
-		// Pending payments.
269
-		if ( $payment_status == 'pending' ) {
268
+        // Pending payments.
269
+        if ( $payment_status == 'pending' ) {
270 270
 
271
-			/* translators: %s: pending reason. */
272
-			$invoice->update_status( 'wpi-onhold', sprintf( __( 'Payment pending (%s).', 'invoicing' ), $posted['pending_reason'] ) );
271
+            /* translators: %s: pending reason. */
272
+            $invoice->update_status( 'wpi-onhold', sprintf( __( 'Payment pending (%s).', 'invoicing' ), $posted['pending_reason'] ) );
273 273
 
274
-			return wpinv_error_log( 'Invoice marked as "payment held".', false );
275
-		}
274
+            return wpinv_error_log( 'Invoice marked as "payment held".', false );
275
+        }
276 276
 
277
-		/* translators: %s: payment status. */
278
-		$invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), sanitize_text_field( $posted['payment_status'] ) ) );
277
+        /* translators: %s: payment status. */
278
+        $invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), sanitize_text_field( $posted['payment_status'] ) ) );
279 279
 
280
-	}
280
+    }
281 281
 
282
-	/**
283
-	 * Handles one time payments.
284
-	 *
285
-	 * @param WPInv_Invoice $invoice  Invoice object.
286
-	 * @param array    $posted Posted data.
287
-	 */
288
-	protected function ipn_txn_cart( $invoice, $posted ) {
289
-		$this->ipn_txn_web_accept( $invoice, $posted );
290
-	}
282
+    /**
283
+     * Handles one time payments.
284
+     *
285
+     * @param WPInv_Invoice $invoice  Invoice object.
286
+     * @param array    $posted Posted data.
287
+     */
288
+    protected function ipn_txn_cart( $invoice, $posted ) {
289
+        $this->ipn_txn_web_accept( $invoice, $posted );
290
+    }
291 291
 
292
-	/**
293
-	 * Handles subscription sign ups.
294
-	 *
295
-	 * @param WPInv_Invoice $invoice  Invoice object.
296
-	 * @param array    $posted Posted data.
297
-	 */
298
-	protected function ipn_txn_subscr_signup( $invoice, $posted ) {
292
+    /**
293
+     * Handles subscription sign ups.
294
+     *
295
+     * @param WPInv_Invoice $invoice  Invoice object.
296
+     * @param array    $posted Posted data.
297
+     */
298
+    protected function ipn_txn_subscr_signup( $invoice, $posted ) {
299 299
 
300
-		wpinv_error_log( 'Processing subscription signup', false );
300
+        wpinv_error_log( 'Processing subscription signup', false );
301 301
 
302
-		// Make sure the invoice has a subscription.
303
-		$subscription = getpaid_get_invoice_subscription( $invoice );
302
+        // Make sure the invoice has a subscription.
303
+        $subscription = getpaid_get_invoice_subscription( $invoice );
304 304
 
305
-		if ( empty( $subscription ) ) {
306
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
307
-		}
305
+        if ( empty( $subscription ) ) {
306
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
307
+        }
308 308
 
309
-		wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
309
+        wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
310 310
 
311
-		// Validate the IPN.
312
-		$business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
313
-		$this->validate_ipn_receiver_email( $invoice, $business_email );
314
-		$this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
311
+        // Validate the IPN.
312
+        $business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
313
+        $this->validate_ipn_receiver_email( $invoice, $business_email );
314
+        $this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
315 315
 
316
-		// Activate the subscription.
317
-		$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
318
-		$subscription->set_date_created( current_time( 'mysql' ) );
319
-		$subscription->set_expiration( date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ) );
320
-		$subscription->set_profile_id( sanitize_text_field( $posted['subscr_id'] ) );
321
-		$subscription->activate();
316
+        // Activate the subscription.
317
+        $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
318
+        $subscription->set_date_created( current_time( 'mysql' ) );
319
+        $subscription->set_expiration( date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ) );
320
+        $subscription->set_profile_id( sanitize_text_field( $posted['subscr_id'] ) );
321
+        $subscription->activate();
322 322
 
323
-		// Set the transaction id.
324
-		if ( ! empty( $posted['txn_id'] ) ) {
325
-			$invoice->add_note( sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true );
326
-			$invoice->set_transaction_id( $posted['txn_id'] );
327
-		}
323
+        // Set the transaction id.
324
+        if ( ! empty( $posted['txn_id'] ) ) {
325
+            $invoice->add_note( sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true );
326
+            $invoice->set_transaction_id( $posted['txn_id'] );
327
+        }
328 328
 
329
-		// Update the payment status.
330
-		$invoice->mark_paid();
329
+        // Update the payment status.
330
+        $invoice->mark_paid();
331 331
 
332
-		$invoice->add_note( sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
332
+        $invoice->add_note( sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
333 333
 
334
-		wpinv_error_log( 'Subscription started.', false );
335
-	}
334
+        wpinv_error_log( 'Subscription started.', false );
335
+    }
336 336
 
337
-	/**
338
-	 * Handles subscription renewals.
339
-	 *
340
-	 * @param WPInv_Invoice $invoice  Invoice object.
341
-	 * @param array    $posted Posted data.
342
-	 */
343
-	protected function ipn_txn_subscr_payment( $invoice, $posted ) {
337
+    /**
338
+     * Handles subscription renewals.
339
+     *
340
+     * @param WPInv_Invoice $invoice  Invoice object.
341
+     * @param array    $posted Posted data.
342
+     */
343
+    protected function ipn_txn_subscr_payment( $invoice, $posted ) {
344 344
 
345
-		// Make sure the invoice has a subscription.
346
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
345
+        // Make sure the invoice has a subscription.
346
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
347 347
 
348
-		if ( empty( $subscription ) ) {
349
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
350
-		}
348
+        if ( empty( $subscription ) ) {
349
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
350
+        }
351 351
 
352
-		wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
352
+        wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
353 353
 
354
-		// PayPal sends a subscr_payment for the first payment too.
355
-		$date_completed = getpaid_format_date( $invoice->get_date_completed() );
356
-		$date_created   = getpaid_format_date( $invoice->get_date_created() );
357
-		$today_date     = getpaid_format_date( current_time( 'mysql' ) );
358
-		$payment_date   = getpaid_format_date( $posted['payment_date'] );
359
-		$subscribe_date = getpaid_format_date( $subscription->get_date_created() );
360
-		$dates          = array_filter( compact( 'date_completed', 'date_created', 'subscribe_date' ) );
354
+        // PayPal sends a subscr_payment for the first payment too.
355
+        $date_completed = getpaid_format_date( $invoice->get_date_completed() );
356
+        $date_created   = getpaid_format_date( $invoice->get_date_created() );
357
+        $today_date     = getpaid_format_date( current_time( 'mysql' ) );
358
+        $payment_date   = getpaid_format_date( $posted['payment_date'] );
359
+        $subscribe_date = getpaid_format_date( $subscription->get_date_created() );
360
+        $dates          = array_filter( compact( 'date_completed', 'date_created', 'subscribe_date' ) );
361 361
 
362
-		foreach( $dates as $date ) {
362
+        foreach( $dates as $date ) {
363 363
 
364
-			if ( $date !== $today_date && $date !== $payment_date ) {
365
-				continue;
366
-			}
364
+            if ( $date !== $today_date && $date !== $payment_date ) {
365
+                continue;
366
+            }
367 367
 
368
-			if ( ! empty( $posted['txn_id'] ) ) {
369
-				$invoice->set_transaction_id( sanitize_text_field( $posted['txn_id'] ) );	
370
-				$invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , sanitize_text_field( $posted['txn_id'] ) ), false, false, true );
371
-			}
368
+            if ( ! empty( $posted['txn_id'] ) ) {
369
+                $invoice->set_transaction_id( sanitize_text_field( $posted['txn_id'] ) );	
370
+                $invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , sanitize_text_field( $posted['txn_id'] ) ), false, false, true );
371
+            }
372 372
 
373
-			return $invoice->mark_paid();
374
-
375
-		}
373
+            return $invoice->mark_paid();
374
+
375
+        }
376 376
 
377
-		wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false );
378
-
379
-		// Abort if the payment is already recorded.
380
-		if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) {
381
-			return wpinv_error_log( 'Aborting, Transaction ' . $posted['txn_id'] .' has already been processed', false );
382
-		}
383
-
384
-		$args = array(
385
-			'transaction_id' => $posted['txn_id'],
386
-			'gateway'        => $this->id,
387
-		);
388
-
389
-		$invoice = wpinv_get_invoice( $subscription->add_payment( $args ) );
377
+        wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false );
378
+
379
+        // Abort if the payment is already recorded.
380
+        if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) {
381
+            return wpinv_error_log( 'Aborting, Transaction ' . $posted['txn_id'] .' has already been processed', false );
382
+        }
383
+
384
+        $args = array(
385
+            'transaction_id' => $posted['txn_id'],
386
+            'gateway'        => $this->id,
387
+        );
388
+
389
+        $invoice = wpinv_get_invoice( $subscription->add_payment( $args ) );
390 390
 
391
-		if ( empty( $invoice ) ) {
392
-			return;
393
-		}
391
+        if ( empty( $invoice ) ) {
392
+            return;
393
+        }
394 394
 
395
-		$invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true );
396
-		$invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
395
+        $invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true );
396
+        $invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
397 397
 
398
-		$subscription->renew();
399
-		wpinv_error_log( 'Subscription renewed.', false );
398
+        $subscription->renew();
399
+        wpinv_error_log( 'Subscription renewed.', false );
400 400
 
401
-	}
401
+    }
402 402
 
403
-	/**
404
-	 * Handles subscription cancelations.
405
-	 *
406
-	 * @param WPInv_Invoice $invoice  Invoice object.
407
-	 */
408
-	protected function ipn_txn_subscr_cancel( $invoice ) {
403
+    /**
404
+     * Handles subscription cancelations.
405
+     *
406
+     * @param WPInv_Invoice $invoice  Invoice object.
407
+     */
408
+    protected function ipn_txn_subscr_cancel( $invoice ) {
409 409
 
410
-		// Make sure the invoice has a subscription.
411
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
412
-
413
-		if ( empty( $subscription ) ) {
414
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
415
-		}
416
-
417
-		wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id(), false );
418
-		$subscription->cancel();
419
-		wpinv_error_log( 'Subscription cancelled.', false );
410
+        // Make sure the invoice has a subscription.
411
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
412
+
413
+        if ( empty( $subscription ) ) {
414
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
415
+        }
416
+
417
+        wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id(), false );
418
+        $subscription->cancel();
419
+        wpinv_error_log( 'Subscription cancelled.', false );
420 420
 
421
-	}
421
+    }
422 422
 
423
-	/**
424
-	 * Handles subscription completions.
425
-	 *
426
-	 * @param WPInv_Invoice $invoice  Invoice object.
427
-	 * @param array    $posted Posted data.
428
-	 */
429
-	protected function ipn_txn_subscr_eot( $invoice ) {
423
+    /**
424
+     * Handles subscription completions.
425
+     *
426
+     * @param WPInv_Invoice $invoice  Invoice object.
427
+     * @param array    $posted Posted data.
428
+     */
429
+    protected function ipn_txn_subscr_eot( $invoice ) {
430 430
 
431
-		// Make sure the invoice has a subscription.
432
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
431
+        // Make sure the invoice has a subscription.
432
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
433 433
 
434
-		if ( empty( $subscription ) ) {
435
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
436
-		}
434
+        if ( empty( $subscription ) ) {
435
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
436
+        }
437 437
 
438
-		wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id(), false );
439
-		$subscription->complete();
440
-		wpinv_error_log( 'Subscription completed.', false );
438
+        wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id(), false );
439
+        $subscription->complete();
440
+        wpinv_error_log( 'Subscription completed.', false );
441 441
 
442
-	}
442
+    }
443 443
 
444
-	/**
445
-	 * Handles subscription fails.
446
-	 *
447
-	 * @param WPInv_Invoice $invoice  Invoice object.
448
-	 * @param array    $posted Posted data.
449
-	 */
450
-	protected function ipn_txn_subscr_failed( $invoice ) {
444
+    /**
445
+     * Handles subscription fails.
446
+     *
447
+     * @param WPInv_Invoice $invoice  Invoice object.
448
+     * @param array    $posted Posted data.
449
+     */
450
+    protected function ipn_txn_subscr_failed( $invoice ) {
451 451
 
452
-		// Make sure the invoice has a subscription.
453
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
452
+        // Make sure the invoice has a subscription.
453
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
454 454
 
455
-		if ( empty( $subscription ) ) {
456
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
457
-		}
455
+        if ( empty( $subscription ) ) {
456
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
457
+        }
458 458
 
459
-		wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id(), false );
460
-		$subscription->failing();
461
-		wpinv_error_log( 'Subscription marked as failing.', false );
459
+        wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id(), false );
460
+        $subscription->failing();
461
+        wpinv_error_log( 'Subscription marked as failing.', false );
462 462
 
463
-	}
463
+    }
464 464
 
465
-	/**
466
-	 * Handles subscription suspensions.
467
-	 *
468
-	 * @param WPInv_Invoice $invoice  Invoice object.
469
-	 * @param array    $posted Posted data.
470
-	 */
471
-	protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment( $invoice ) {
465
+    /**
466
+     * Handles subscription suspensions.
467
+     *
468
+     * @param WPInv_Invoice $invoice  Invoice object.
469
+     * @param array    $posted Posted data.
470
+     */
471
+    protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment( $invoice ) {
472 472
 
473
-		// Make sure the invoice has a subscription.
474
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
473
+        // Make sure the invoice has a subscription.
474
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
475 475
 
476
-		if ( empty( $subscription ) ) {
477
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
478
-		}
479
-
480
-		wpinv_error_log( 'Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false );
481
-		$subscription->cancel();
482
-		wpinv_error_log( 'Subscription cancelled.', false );
483
-	}
476
+        if ( empty( $subscription ) ) {
477
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
478
+        }
479
+
480
+        wpinv_error_log( 'Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false );
481
+        $subscription->cancel();
482
+        wpinv_error_log( 'Subscription cancelled.', false );
483
+    }
484 484
 
485 485
 }
Please login to merge, or discard this patch.
Spacing   +151 added lines, -151 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 IPN handler class.
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @param GetPaid_Paypal_Gateway $gateway
33 33
 	 */
34
-	public function __construct( $gateway ) {
34
+	public function __construct($gateway) {
35 35
 		$this->gateway = $gateway;
36 36
 		$this->verify_ipn();
37 37
 	}
@@ -43,37 +43,37 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public function verify_ipn() {
45 45
 
46
-		wpinv_error_log( 'GetPaid PayPal IPN Handler', false );
46
+		wpinv_error_log('GetPaid PayPal IPN Handler', false);
47 47
 
48 48
 		// Validate the IPN.
49
-		if ( empty( $_POST ) || ! $this->validate_ipn() ) {
50
-			wp_die( 'PayPal IPN Request Failure', 500 );
49
+		if (empty($_POST) || !$this->validate_ipn()) {
50
+			wp_die('PayPal IPN Request Failure', 500);
51 51
 		}
52 52
 
53 53
 		// Process the IPN.
54
-		$posted  = wp_unslash( $_POST );
55
-		$invoice = $this->get_ipn_invoice( $posted );
54
+		$posted  = wp_unslash($_POST);
55
+		$invoice = $this->get_ipn_invoice($posted);
56 56
 
57 57
 		// Abort if it was not paid by our gateway.
58
-		if ( $this->id != $invoice->get_gateway() ) {
59
-			wpinv_error_log( 'Aborting, Invoice was not paid via PayPal', false );
60
-			wp_die( 'Invoice not paid via PayPal', 200 );
58
+		if ($this->id != $invoice->get_gateway()) {
59
+			wpinv_error_log('Aborting, Invoice was not paid via PayPal', false);
60
+			wp_die('Invoice not paid via PayPal', 200);
61 61
 		}
62 62
 
63
-		$posted['payment_status'] = isset( $posted['payment_status'] ) ? sanitize_key( strtolower( $posted['payment_status'] ) ) : '';
64
-		$posted['txn_type']       = sanitize_key( strtolower( $posted['txn_type'] ) );
63
+		$posted['payment_status'] = isset($posted['payment_status']) ? sanitize_key(strtolower($posted['payment_status'])) : '';
64
+		$posted['txn_type']       = sanitize_key(strtolower($posted['txn_type']));
65 65
 
66
-		wpinv_error_log( 'Payment status:' . $posted['payment_status'], false );
67
-		wpinv_error_log( 'IPN Type:' . $posted['txn_type'], false );
66
+		wpinv_error_log('Payment status:' . $posted['payment_status'], false);
67
+		wpinv_error_log('IPN Type:' . $posted['txn_type'], false);
68 68
 
69
-		if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) {
70
-			call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted );
71
-			wpinv_error_log( 'Done processing IPN', false );
72
-			wp_die( 'Processed', 200 );
69
+		if (method_exists($this, 'ipn_txn_' . $posted['txn_type'])) {
70
+			call_user_func(array($this, 'ipn_txn_' . $posted['txn_type']), $invoice, $posted);
71
+			wpinv_error_log('Done processing IPN', false);
72
+			wp_die('Processed', 200);
73 73
 		}
74 74
 
75
-		wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'], false );
76
-		wp_die( 'Unsupported IPN type', 200 );
75
+		wpinv_error_log('Aborting, Unsupported IPN type:' . $posted['txn_type'], false);
76
+		wp_die('Unsupported IPN type', 200);
77 77
 
78 78
 	}
79 79
 
@@ -83,22 +83,22 @@  discard block
 block discarded – undo
83 83
 	 * @param array $posted
84 84
 	 * @return WPInv_Invoice
85 85
 	 */
86
-	protected function get_ipn_invoice( $posted ) {
86
+	protected function get_ipn_invoice($posted) {
87 87
 
88
-		wpinv_error_log( 'Retrieving PayPal IPN Response Invoice', false );
88
+		wpinv_error_log('Retrieving PayPal IPN Response Invoice', false);
89 89
 
90
-		if ( ! empty( $posted['custom'] ) ) {
91
-			$invoice = new WPInv_Invoice( $posted['custom'] );
90
+		if (!empty($posted['custom'])) {
91
+			$invoice = new WPInv_Invoice($posted['custom']);
92 92
 
93
-			if ( $invoice->exists() ) {
94
-				wpinv_error_log( 'Found invoice #' . $invoice->get_number(), false );
93
+			if ($invoice->exists()) {
94
+				wpinv_error_log('Found invoice #' . $invoice->get_number(), false);
95 95
 				return $invoice;
96 96
 			}
97 97
 
98 98
 		}
99 99
 
100
-		wpinv_error_log( 'Could not retrieve the associated invoice.', false );
101
-		wp_die( 'Could not retrieve the associated invoice.', 200 );
100
+		wpinv_error_log('Could not retrieve the associated invoice.', false);
101
+		wp_die('Could not retrieve the associated invoice.', 200);
102 102
 	}
103 103
 
104 104
 	/**
@@ -106,14 +106,14 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	protected function validate_ipn() {
108 108
 
109
-		wpinv_error_log( 'Validating PayPal IPN response', false );
109
+		wpinv_error_log('Validating PayPal IPN response', false);
110 110
 
111 111
 		// Retrieve the associated invoice.
112
-		$posted  = wp_unslash( $_POST );
113
-		$invoice = $this->get_ipn_invoice( $posted );
112
+		$posted  = wp_unslash($_POST);
113
+		$invoice = $this->get_ipn_invoice($posted);
114 114
 
115
-		if ( $this->gateway->is_sandbox( $invoice ) ) {
116
-			wpinv_error_log( $posted, 'Invoice was processed in sandbox hence logging the posted data', false );
115
+		if ($this->gateway->is_sandbox($invoice)) {
116
+			wpinv_error_log($posted, 'Invoice was processed in sandbox hence logging the posted data', false);
117 117
 		}
118 118
 
119 119
 		// Validate the IPN.
@@ -130,20 +130,20 @@  discard block
 block discarded – undo
130 130
 		);
131 131
 
132 132
 		// Post back to get a response.
133
-		$response = wp_safe_remote_post( $this->gateway->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params );
133
+		$response = wp_safe_remote_post($this->gateway->is_sandbox($invoice) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params);
134 134
 
135 135
 		// Check to see if the request was valid.
136
-		if ( ! is_wp_error( $response ) && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {
137
-			wpinv_error_log( 'Received valid response from PayPal IPN: ' . $response['body'], false );
136
+		if (!is_wp_error($response) && $response['response']['code'] < 300 && strstr($response['body'], 'VERIFIED')) {
137
+			wpinv_error_log('Received valid response from PayPal IPN: ' . $response['body'], false);
138 138
 			return true;
139 139
 		}
140 140
 
141
-		if ( is_wp_error( $response ) ) {
142
-			wpinv_error_log( $response->get_error_message(), 'Received invalid response from PayPal IPN' );
141
+		if (is_wp_error($response)) {
142
+			wpinv_error_log($response->get_error_message(), 'Received invalid response from PayPal IPN');
143 143
 			return false;
144 144
 		}
145 145
 
146
-		wpinv_error_log( $response['body'], 'Received invalid response from PayPal IPN' );
146
+		wpinv_error_log($response['body'], 'Received invalid response from PayPal IPN');
147 147
 		return false;
148 148
 
149 149
 	}
@@ -154,17 +154,17 @@  discard block
 block discarded – undo
154 154
 	 * @param WPInv_Invoice $invoice          Invoice object.
155 155
 	 * @param string   $currency currency to validate.
156 156
 	 */
157
-	protected function validate_ipn_currency( $invoice, $currency ) {
157
+	protected function validate_ipn_currency($invoice, $currency) {
158 158
 
159
-		if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) {
159
+		if (strtolower($invoice->get_currency()) !== strtolower($currency)) {
160 160
 
161 161
 			/* translators: %s: currency code. */
162
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) );
162
+			$invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal currencies do not match (code %s).', 'invoicing'), $currency));
163 163
 
164
-			wpinv_error_log( "Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true );
164
+			wpinv_error_log("Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true);
165 165
 		}
166 166
 
167
-		wpinv_error_log( $currency, 'Validated IPN Currency', false );
167
+		wpinv_error_log($currency, 'Validated IPN Currency', false);
168 168
 	}
169 169
 
170 170
 	/**
@@ -173,16 +173,16 @@  discard block
 block discarded – undo
173 173
 	 * @param WPInv_Invoice $invoice          Invoice object.
174 174
 	 * @param float   $amount amount to validate.
175 175
 	 */
176
-	protected function validate_ipn_amount( $invoice, $amount ) {
177
-		if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
176
+	protected function validate_ipn_amount($invoice, $amount) {
177
+		if (number_format($invoice->get_total(), 2, '.', '') !== number_format($amount, 2, '.', '')) {
178 178
 
179 179
 			/* translators: %s: Amount. */
180
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) );
180
+			$invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal amounts do not match (gross %s).', 'invoicing'), $amount));
181 181
 
182
-			wpinv_error_log( "Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true );
182
+			wpinv_error_log("Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true);
183 183
 		}
184 184
 
185
-		wpinv_error_log( $amount, 'Validated IPN Amount', false );
185
+		wpinv_error_log($amount, 'Validated IPN Amount', false);
186 186
 	}
187 187
 
188 188
 	/**
@@ -191,19 +191,19 @@  discard block
 block discarded – undo
191 191
 	 * @param WPInv_Invoice $invoice          Invoice object.
192 192
 	 * @param string   $receiver_email Email to validate.
193 193
 	 */
194
-	protected function validate_ipn_receiver_email( $invoice, $receiver_email ) {
195
-		$paypal_email = wpinv_get_option( 'paypal_email' );
194
+	protected function validate_ipn_receiver_email($invoice, $receiver_email) {
195
+		$paypal_email = wpinv_get_option('paypal_email');
196 196
 
197
-		if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) {
198
-			wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" );
197
+		if (strcasecmp(trim($receiver_email), trim($paypal_email)) !== 0) {
198
+			wpinv_record_gateway_error('IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}");
199 199
 
200 200
 			/* translators: %s: email address . */
201
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) );
201
+			$invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal IPN response from a different email address (%s).', 'invoicing'), $receiver_email));
202 202
 
203
-			return wpinv_error_log( "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true );
203
+			return wpinv_error_log("IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true);
204 204
 		}
205 205
 
206
-		wpinv_error_log( 'Validated PayPal Email', false );
206
+		wpinv_error_log('Validated PayPal Email', false);
207 207
 	}
208 208
 
209 209
 	/**
@@ -212,70 +212,70 @@  discard block
 block discarded – undo
212 212
 	 * @param WPInv_Invoice $invoice  Invoice object.
213 213
 	 * @param array    $posted Posted data.
214 214
 	 */
215
-	protected function ipn_txn_web_accept( $invoice, $posted ) {
215
+	protected function ipn_txn_web_accept($invoice, $posted) {
216 216
 
217 217
 		// Collect payment details
218
-		$payment_status = strtolower( $posted['payment_status'] );
219
-		$business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
218
+		$payment_status = strtolower($posted['payment_status']);
219
+		$business_email = isset($posted['business']) && is_email($posted['business']) ? trim($posted['business']) : trim($posted['receiver_email']);
220 220
 
221
-		$this->validate_ipn_receiver_email( $invoice, $business_email );
222
-		$this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
221
+		$this->validate_ipn_receiver_email($invoice, $business_email);
222
+		$this->validate_ipn_currency($invoice, $posted['mc_currency']);
223 223
 
224 224
 		// Update the transaction id.
225
-		if ( ! empty( $posted['txn_id'] ) ) {
226
-			$invoice->set_transaction_id( wpinv_clean( $posted['txn_id'] ) );
225
+		if (!empty($posted['txn_id'])) {
226
+			$invoice->set_transaction_id(wpinv_clean($posted['txn_id']));
227 227
 			$invoice->save();
228 228
 		}
229 229
 
230
-		$invoice->add_system_note( __( 'Processing invoice IPN', 'invoicing' ) );
230
+		$invoice->add_system_note(__('Processing invoice IPN', 'invoicing'));
231 231
 
232 232
 		// Process a refund.
233
-		if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
233
+		if ($payment_status == 'refunded' || $payment_status == 'reversed') {
234 234
 
235
-			update_post_meta( $invoice->get_id(), 'refunded_remotely', 1 );
235
+			update_post_meta($invoice->get_id(), 'refunded_remotely', 1);
236 236
 
237
-			if ( ! $invoice->is_refunded() ) {
238
-				$invoice->update_status( 'wpi-refunded', $posted['reason_code'] );
237
+			if (!$invoice->is_refunded()) {
238
+				$invoice->update_status('wpi-refunded', $posted['reason_code']);
239 239
 			}
240 240
 
241
-			return wpinv_error_log( $posted['reason_code'], false );
241
+			return wpinv_error_log($posted['reason_code'], false);
242 242
 		}
243 243
 
244 244
 		// Process payments.
245
-		if ( $payment_status == 'completed' ) {
245
+		if ($payment_status == 'completed') {
246 246
 
247
-			if ( $invoice->is_paid() && 'wpi_processing' != $invoice->get_status() ) {
248
-				return wpinv_error_log( 'Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false );
247
+			if ($invoice->is_paid() && 'wpi_processing' != $invoice->get_status()) {
248
+				return wpinv_error_log('Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false);
249 249
 			}
250 250
 
251
-			$this->validate_ipn_amount( $invoice, $posted['mc_gross'] );
251
+			$this->validate_ipn_amount($invoice, $posted['mc_gross']);
252 252
 
253 253
 			$note = '';
254 254
 
255
-			if ( ! empty( $posted['mc_fee'] ) ) {
256
-				$note = sprintf( __( 'PayPal Transaction Fee %.', 'invoicing' ), sanitize_text_field( $posted['mc_fee'] ) );
255
+			if (!empty($posted['mc_fee'])) {
256
+				$note = sprintf(__('PayPal Transaction Fee %.', 'invoicing'), sanitize_text_field($posted['mc_fee']));
257 257
 			}
258 258
 
259
-			if ( ! empty( $posted['payer_status'] ) ) {
260
-				$note = ' ' . sprintf( __( 'Buyer status %.', 'invoicing' ), sanitize_text_field( $posted['payer_status'] ) );
259
+			if (!empty($posted['payer_status'])) {
260
+				$note = ' ' . sprintf(__('Buyer status %.', 'invoicing'), sanitize_text_field($posted['payer_status']));
261 261
 			}
262 262
 
263
-			$invoice->mark_paid( ( ! empty( $posted['txn_id'] ) ? sanitize_text_field( $posted['txn_id'] ) : '' ), trim( $note ) );
264
-			return wpinv_error_log( 'Invoice marked as paid.', false );
263
+			$invoice->mark_paid((!empty($posted['txn_id']) ? sanitize_text_field($posted['txn_id']) : ''), trim($note));
264
+			return wpinv_error_log('Invoice marked as paid.', false);
265 265
 
266 266
 		}
267 267
 
268 268
 		// Pending payments.
269
-		if ( $payment_status == 'pending' ) {
269
+		if ($payment_status == 'pending') {
270 270
 
271 271
 			/* translators: %s: pending reason. */
272
-			$invoice->update_status( 'wpi-onhold', sprintf( __( 'Payment pending (%s).', 'invoicing' ), $posted['pending_reason'] ) );
272
+			$invoice->update_status('wpi-onhold', sprintf(__('Payment pending (%s).', 'invoicing'), $posted['pending_reason']));
273 273
 
274
-			return wpinv_error_log( 'Invoice marked as "payment held".', false );
274
+			return wpinv_error_log('Invoice marked as "payment held".', false);
275 275
 		}
276 276
 
277 277
 		/* translators: %s: payment status. */
278
-		$invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), sanitize_text_field( $posted['payment_status'] ) ) );
278
+		$invoice->update_status('wpi-failed', sprintf(__('Payment %s via IPN.', 'invoicing'), sanitize_text_field($posted['payment_status'])));
279 279
 
280 280
 	}
281 281
 
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
 	 * @param WPInv_Invoice $invoice  Invoice object.
286 286
 	 * @param array    $posted Posted data.
287 287
 	 */
288
-	protected function ipn_txn_cart( $invoice, $posted ) {
289
-		$this->ipn_txn_web_accept( $invoice, $posted );
288
+	protected function ipn_txn_cart($invoice, $posted) {
289
+		$this->ipn_txn_web_accept($invoice, $posted);
290 290
 	}
291 291
 
292 292
 	/**
@@ -295,43 +295,43 @@  discard block
 block discarded – undo
295 295
 	 * @param WPInv_Invoice $invoice  Invoice object.
296 296
 	 * @param array    $posted Posted data.
297 297
 	 */
298
-	protected function ipn_txn_subscr_signup( $invoice, $posted ) {
298
+	protected function ipn_txn_subscr_signup($invoice, $posted) {
299 299
 
300
-		wpinv_error_log( 'Processing subscription signup', false );
300
+		wpinv_error_log('Processing subscription signup', false);
301 301
 
302 302
 		// Make sure the invoice has a subscription.
303
-		$subscription = getpaid_get_invoice_subscription( $invoice );
303
+		$subscription = getpaid_get_invoice_subscription($invoice);
304 304
 
305
-		if ( empty( $subscription ) ) {
306
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
305
+		if (empty($subscription)) {
306
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
307 307
 		}
308 308
 
309
-		wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
309
+		wpinv_error_log('Found subscription #' . $subscription->get_id(), false);
310 310
 
311 311
 		// Validate the IPN.
312
-		$business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
313
-		$this->validate_ipn_receiver_email( $invoice, $business_email );
314
-		$this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
312
+		$business_email = isset($posted['business']) && is_email($posted['business']) ? trim($posted['business']) : trim($posted['receiver_email']);
313
+		$this->validate_ipn_receiver_email($invoice, $business_email);
314
+		$this->validate_ipn_currency($invoice, $posted['mc_currency']);
315 315
 
316 316
 		// Activate the subscription.
317
-		$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
318
-		$subscription->set_date_created( current_time( 'mysql' ) );
319
-		$subscription->set_expiration( date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ) );
320
-		$subscription->set_profile_id( sanitize_text_field( $posted['subscr_id'] ) );
317
+		$duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created());
318
+		$subscription->set_date_created(current_time('mysql'));
319
+		$subscription->set_expiration(date('Y-m-d H:i:s', (current_time('timestamp') + $duration)));
320
+		$subscription->set_profile_id(sanitize_text_field($posted['subscr_id']));
321 321
 		$subscription->activate();
322 322
 
323 323
 		// Set the transaction id.
324
-		if ( ! empty( $posted['txn_id'] ) ) {
325
-			$invoice->add_note( sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true );
326
-			$invoice->set_transaction_id( $posted['txn_id'] );
324
+		if (!empty($posted['txn_id'])) {
325
+			$invoice->add_note(sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $posted['txn_id']), false, false, true);
326
+			$invoice->set_transaction_id($posted['txn_id']);
327 327
 		}
328 328
 
329 329
 		// Update the payment status.
330 330
 		$invoice->mark_paid();
331 331
 
332
-		$invoice->add_note( sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
332
+		$invoice->add_note(sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $posted['subscr_id']), false, false, true);
333 333
 
334
-		wpinv_error_log( 'Subscription started.', false );
334
+		wpinv_error_log('Subscription started.', false);
335 335
 	}
336 336
 
337 337
 	/**
@@ -340,45 +340,45 @@  discard block
 block discarded – undo
340 340
 	 * @param WPInv_Invoice $invoice  Invoice object.
341 341
 	 * @param array    $posted Posted data.
342 342
 	 */
343
-	protected function ipn_txn_subscr_payment( $invoice, $posted ) {
343
+	protected function ipn_txn_subscr_payment($invoice, $posted) {
344 344
 
345 345
 		// Make sure the invoice has a subscription.
346
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
346
+		$subscription = getpaid_subscriptions()->get_invoice_subscription($invoice);
347 347
 
348
-		if ( empty( $subscription ) ) {
349
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
348
+		if (empty($subscription)) {
349
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
350 350
 		}
351 351
 
352
-		wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
352
+		wpinv_error_log('Found subscription #' . $subscription->get_id(), false);
353 353
 
354 354
 		// PayPal sends a subscr_payment for the first payment too.
355
-		$date_completed = getpaid_format_date( $invoice->get_date_completed() );
356
-		$date_created   = getpaid_format_date( $invoice->get_date_created() );
357
-		$today_date     = getpaid_format_date( current_time( 'mysql' ) );
358
-		$payment_date   = getpaid_format_date( $posted['payment_date'] );
359
-		$subscribe_date = getpaid_format_date( $subscription->get_date_created() );
360
-		$dates          = array_filter( compact( 'date_completed', 'date_created', 'subscribe_date' ) );
355
+		$date_completed = getpaid_format_date($invoice->get_date_completed());
356
+		$date_created   = getpaid_format_date($invoice->get_date_created());
357
+		$today_date     = getpaid_format_date(current_time('mysql'));
358
+		$payment_date   = getpaid_format_date($posted['payment_date']);
359
+		$subscribe_date = getpaid_format_date($subscription->get_date_created());
360
+		$dates          = array_filter(compact('date_completed', 'date_created', 'subscribe_date'));
361 361
 
362
-		foreach( $dates as $date ) {
362
+		foreach ($dates as $date) {
363 363
 
364
-			if ( $date !== $today_date && $date !== $payment_date ) {
364
+			if ($date !== $today_date && $date !== $payment_date) {
365 365
 				continue;
366 366
 			}
367 367
 
368
-			if ( ! empty( $posted['txn_id'] ) ) {
369
-				$invoice->set_transaction_id( sanitize_text_field( $posted['txn_id'] ) );	
370
-				$invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , sanitize_text_field( $posted['txn_id'] ) ), false, false, true );
368
+			if (!empty($posted['txn_id'])) {
369
+				$invoice->set_transaction_id(sanitize_text_field($posted['txn_id']));	
370
+				$invoice->add_note(wp_sprintf(__('PayPal Transaction ID: %s', 'invoicing'), sanitize_text_field($posted['txn_id'])), false, false, true);
371 371
 			}
372 372
 
373 373
 			return $invoice->mark_paid();
374 374
 
375 375
 		}
376 376
 
377
-		wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false );
377
+		wpinv_error_log('Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false);
378 378
 
379 379
 		// Abort if the payment is already recorded.
380
-		if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) {
381
-			return wpinv_error_log( 'Aborting, Transaction ' . $posted['txn_id'] .' has already been processed', false );
380
+		if (wpinv_get_id_by_transaction_id($posted['txn_id'])) {
381
+			return wpinv_error_log('Aborting, Transaction ' . $posted['txn_id'] . ' has already been processed', false);
382 382
 		}
383 383
 
384 384
 		$args = array(
@@ -386,17 +386,17 @@  discard block
 block discarded – undo
386 386
 			'gateway'        => $this->id,
387 387
 		);
388 388
 
389
-		$invoice = wpinv_get_invoice( $subscription->add_payment( $args ) );
389
+		$invoice = wpinv_get_invoice($subscription->add_payment($args));
390 390
 
391
-		if ( empty( $invoice ) ) {
391
+		if (empty($invoice)) {
392 392
 			return;
393 393
 		}
394 394
 
395
-		$invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true );
396
-		$invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
395
+		$invoice->add_note(wp_sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $posted['txn_id']), false, false, true);
396
+		$invoice->add_note(wp_sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $posted['subscr_id']), false, false, true);
397 397
 
398 398
 		$subscription->renew();
399
-		wpinv_error_log( 'Subscription renewed.', false );
399
+		wpinv_error_log('Subscription renewed.', false);
400 400
 
401 401
 	}
402 402
 
@@ -405,18 +405,18 @@  discard block
 block discarded – undo
405 405
 	 *
406 406
 	 * @param WPInv_Invoice $invoice  Invoice object.
407 407
 	 */
408
-	protected function ipn_txn_subscr_cancel( $invoice ) {
408
+	protected function ipn_txn_subscr_cancel($invoice) {
409 409
 
410 410
 		// Make sure the invoice has a subscription.
411
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
411
+		$subscription = getpaid_subscriptions()->get_invoice_subscription($invoice);
412 412
 
413
-		if ( empty( $subscription ) ) {
414
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
413
+		if (empty($subscription)) {
414
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
415 415
 		}
416 416
 
417
-		wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id(), false );
417
+		wpinv_error_log('Processing subscription cancellation for the invoice ' . $invoice->get_id(), false);
418 418
 		$subscription->cancel();
419
-		wpinv_error_log( 'Subscription cancelled.', false );
419
+		wpinv_error_log('Subscription cancelled.', false);
420 420
 
421 421
 	}
422 422
 
@@ -426,18 +426,18 @@  discard block
 block discarded – undo
426 426
 	 * @param WPInv_Invoice $invoice  Invoice object.
427 427
 	 * @param array    $posted Posted data.
428 428
 	 */
429
-	protected function ipn_txn_subscr_eot( $invoice ) {
429
+	protected function ipn_txn_subscr_eot($invoice) {
430 430
 
431 431
 		// Make sure the invoice has a subscription.
432
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
432
+		$subscription = getpaid_subscriptions()->get_invoice_subscription($invoice);
433 433
 
434
-		if ( empty( $subscription ) ) {
435
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
434
+		if (empty($subscription)) {
435
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
436 436
 		}
437 437
 
438
-		wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id(), false );
438
+		wpinv_error_log('Processing subscription end of life for the invoice ' . $invoice->get_id(), false);
439 439
 		$subscription->complete();
440
-		wpinv_error_log( 'Subscription completed.', false );
440
+		wpinv_error_log('Subscription completed.', false);
441 441
 
442 442
 	}
443 443
 
@@ -447,18 +447,18 @@  discard block
 block discarded – undo
447 447
 	 * @param WPInv_Invoice $invoice  Invoice object.
448 448
 	 * @param array    $posted Posted data.
449 449
 	 */
450
-	protected function ipn_txn_subscr_failed( $invoice ) {
450
+	protected function ipn_txn_subscr_failed($invoice) {
451 451
 
452 452
 		// Make sure the invoice has a subscription.
453
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
453
+		$subscription = getpaid_subscriptions()->get_invoice_subscription($invoice);
454 454
 
455
-		if ( empty( $subscription ) ) {
456
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
455
+		if (empty($subscription)) {
456
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
457 457
 		}
458 458
 
459
-		wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id(), false );
459
+		wpinv_error_log('Processing subscription payment failure for the invoice ' . $invoice->get_id(), false);
460 460
 		$subscription->failing();
461
-		wpinv_error_log( 'Subscription marked as failing.', false );
461
+		wpinv_error_log('Subscription marked as failing.', false);
462 462
 
463 463
 	}
464 464
 
@@ -468,18 +468,18 @@  discard block
 block discarded – undo
468 468
 	 * @param WPInv_Invoice $invoice  Invoice object.
469 469
 	 * @param array    $posted Posted data.
470 470
 	 */
471
-	protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment( $invoice ) {
471
+	protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment($invoice) {
472 472
 
473 473
 		// Make sure the invoice has a subscription.
474
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
474
+		$subscription = getpaid_subscriptions()->get_invoice_subscription($invoice);
475 475
 
476
-		if ( empty( $subscription ) ) {
477
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
476
+		if (empty($subscription)) {
477
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
478 478
 		}
479 479
 
480
-		wpinv_error_log( 'Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false );
480
+		wpinv_error_log('Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false);
481 481
 		$subscription->cancel();
482
-		wpinv_error_log( 'Subscription cancelled.', false );
482
+		wpinv_error_log('Subscription cancelled.', false);
483 483
 	}
484 484
 
485 485
 }
Please login to merge, or discard this patch.
includes/data/admin-settings.php 1 patch
Spacing   +170 added lines, -170 removed lines patch added patch discarded remove patch
@@ -8,99 +8,99 @@  discard block
 block discarded – undo
8 8
  * @version 1.0.19
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 $getpaid_pages = GetPaid_Installer::get_pages();
14
-$pages         = wpinv_get_pages( true );
14
+$pages         = wpinv_get_pages(true);
15 15
     
16 16
 $currencies = wpinv_get_currencies();
17 17
     
18 18
 $currency_code_options = array();
19
-foreach ( $currencies as $code => $name ) {
20
-    $currency_code_options[ $code ] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol( $code ) . ')';
19
+foreach ($currencies as $code => $name) {
20
+    $currency_code_options[$code] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol($code) . ')';
21 21
 }
22 22
 
23 23
 $invoice_number_padd_options = array();
24
-for ( $i = 0; $i <= 20; $i++ ) {
24
+for ($i = 0; $i <= 20; $i++) {
25 25
     $invoice_number_padd_options[$i] = $i;
26 26
 }
27 27
     
28 28
 $currency_symbol = wpinv_currency_symbol();
29 29
     
30 30
 $last_number = $reset_number = '';
31
-if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) {
32
-    $last_invoice_number = preg_replace( '/[^0-9]/', '', $last_invoice_number );
31
+if ($last_invoice_number = get_option('wpinv_last_invoice_number')) {
32
+    $last_invoice_number = preg_replace('/[^0-9]/', '', $last_invoice_number);
33 33
 
34
-    if ( !empty( $last_invoice_number ) ) {
35
-        $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number );
34
+    if (!empty($last_invoice_number)) {
35
+        $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number);
36 36
     }
37 37
 
38 38
     $nonce = wp_create_nonce('reset_invoice_count');
39
-    $reset_number = '<a href="'.add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)).'" class="btn button">'.__('Force Reset Sequence', 'invoicing' ). '</a>';
39
+    $reset_number = '<a href="' . add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)) . '" class="btn button">' . __('Force Reset Sequence', 'invoicing') . '</a>';
40 40
 }
41 41
     
42 42
 $alert_wrapper_start = '<p style="color: #F00">';
43 43
 $alert_wrapper_close = '</p>';
44 44
 
45 45
 return array(
46
-    'general' => apply_filters( 'wpinv_settings_general',
46
+    'general' => apply_filters('wpinv_settings_general',
47 47
         array(
48 48
             'main' => array(
49 49
                 'location_settings' => array(
50 50
                     'id'   => 'location_settings',
51
-                    'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>',
51
+                    'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>',
52 52
                     'desc' => '',
53 53
                     'type' => 'header',
54 54
                 ),
55 55
                 'default_country' => array(
56 56
                     'id'      => 'default_country',
57
-                    'name'    => __( 'Default Country', 'invoicing' ),
58
-                    'desc'    => __( 'Where does your store operate from?', 'invoicing' ),
57
+                    'name'    => __('Default Country', 'invoicing'),
58
+                    'desc'    => __('Where does your store operate from?', 'invoicing'),
59 59
                     'type'    => 'select',
60 60
                     'options' => wpinv_get_country_list(),
61 61
                     'std'     => 'GB',
62 62
                     'class'   => 'wpi_select2',
63
-                    'placeholder' => __( 'Select a country', 'invoicing' ),
63
+                    'placeholder' => __('Select a country', 'invoicing'),
64 64
                 ),
65 65
                 'default_state' => array(
66 66
                     'id'      => 'default_state',
67
-                    'name'    => __( 'Default State / Province', 'invoicing' ),
68
-                    'desc'    => __( 'What state / province does your store operate from?', 'invoicing' ),
67
+                    'name'    => __('Default State / Province', 'invoicing'),
68
+                    'desc'    => __('What state / province does your store operate from?', 'invoicing'),
69 69
                     'type'    => 'country_states',
70 70
                     'class'   => 'wpi_select2',
71
-                    'placeholder' => __( 'Select a state', 'invoicing' ),
71
+                    'placeholder' => __('Select a state', 'invoicing'),
72 72
                 ),
73 73
                 'store_name' => array(
74 74
                     'id'   => 'store_name',
75
-                    'name' => __( 'Store Name', 'invoicing' ),
76
-                    'desc' => __( 'Store name to print on invoices.', 'invoicing' ),
75
+                    'name' => __('Store Name', 'invoicing'),
76
+                    'desc' => __('Store name to print on invoices.', 'invoicing'),
77 77
                     'std'     => get_option('blogname'),
78 78
                     'type' => 'text',
79 79
                 ),
80 80
                 'logo' => array(
81 81
                     'id'   => 'logo',
82
-                    'name' => __( 'Logo URL', 'invoicing' ),
83
-                    'desc' => __( 'Store logo to print on invoices.', 'invoicing' ),
82
+                    'name' => __('Logo URL', 'invoicing'),
83
+                    'desc' => __('Store logo to print on invoices.', 'invoicing'),
84 84
                     'type' => 'text',
85 85
                 ),
86 86
                 'logo_width'      => array(
87 87
                     'id'          => 'logo_width',
88
-                    'name'        => __( 'Logo width', 'invoicing' ),
89
-                    'desc'        => __( 'Logo width to use in invoice image.', 'invoicing' ),
88
+                    'name'        => __('Logo width', 'invoicing'),
89
+                    'desc'        => __('Logo width to use in invoice image.', 'invoicing'),
90 90
                     'type'        => 'number',
91
-                    'placeholder' => __( 'Auto', 'invoicing' ),
91
+                    'placeholder' => __('Auto', 'invoicing'),
92 92
                 ),
93 93
                 'logo_height'     => array(
94 94
                     'id'          => 'logo_height',
95
-                    'name'        => __( 'Logo height', 'invoicing' ),
96
-                    'desc'        => __( 'Logo height to use in invoice image.', 'invoicing' ),
95
+                    'name'        => __('Logo height', 'invoicing'),
96
+                    'desc'        => __('Logo height to use in invoice image.', 'invoicing'),
97 97
                     'type'        => 'number',
98
-                    'placeholder' => __( 'Auto', 'invoicing' ),
98
+                    'placeholder' => __('Auto', 'invoicing'),
99 99
                 ),
100 100
                 'store_address' => array(
101 101
                     'id'   => 'store_address',
102
-                    'name' => __( 'Store Address', 'invoicing' ),
103
-                    'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ),
102
+                    'name' => __('Store Address', 'invoicing'),
103
+                    'desc' => __('Enter the store address to display on invoice', 'invoicing'),
104 104
                     'type' => 'textarea',
105 105
                 ),
106 106
 
@@ -108,114 +108,114 @@  discard block
 block discarded – undo
108 108
             'page_section' => array(
109 109
                 'page_settings' => array(
110 110
                     'id'   => 'page_settings',
111
-                    'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>',
111
+                    'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>',
112 112
                     'desc' => '',
113 113
                     'type' => 'header',
114 114
                 ),
115 115
                 'checkout_page' => array(
116 116
                     'id'          => 'checkout_page',
117
-                    'name'        => __( 'Checkout Page', 'invoicing' ),
118
-                    'desc'        => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ),
117
+                    'name'        => __('Checkout Page', 'invoicing'),
118
+                    'desc'        => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'),
119 119
                     'type'        => 'select',
120 120
                     'options'     => $pages,
121 121
                     'class'       => 'wpi_select2',
122
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
123
-                    'default_content' => empty( $getpaid_pages['checkout_page'] ) ? '' : $getpaid_pages['checkout_page']['content'],
122
+                    'placeholder' => __('Select a page', 'invoicing'),
123
+                    'default_content' => empty($getpaid_pages['checkout_page']) ? '' : $getpaid_pages['checkout_page']['content'],
124 124
                     'help-tip'    => true,
125 125
                 ),
126 126
                 'success_page' => array(
127 127
                     'id'          => 'success_page',
128
-                    'name'        => __( 'Success Page', 'invoicing' ),
129
-                    'desc'        => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ),
128
+                    'name'        => __('Success Page', 'invoicing'),
129
+                    'desc'        => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'),
130 130
                     'type'        => 'select',
131 131
                     'options'     => $pages,
132 132
                     'class'       => 'wpi_select2',
133
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
134
-                    'default_content' => empty( $getpaid_pages['success_page'] ) ? '' : $getpaid_pages['success_page']['content'],
133
+                    'placeholder' => __('Select a page', 'invoicing'),
134
+                    'default_content' => empty($getpaid_pages['success_page']) ? '' : $getpaid_pages['success_page']['content'],
135 135
                     'help-tip'    => true,
136 136
                 ),
137 137
                 'failure_page' => array(
138 138
                     'id'          => 'failure_page',
139
-                    'name'        => __( 'Failed Transaction Page', 'invoicing' ),
140
-                    'desc'        => __( 'This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing' ),
139
+                    'name'        => __('Failed Transaction Page', 'invoicing'),
140
+                    'desc'        => __('This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing'),
141 141
                     'type'        => 'select',
142 142
                     'options'     => $pages,
143 143
                     'class'       => 'wpi_select2',
144
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
145
-                    'default_content' => empty( $getpaid_pages['failure_page'] ) ? '' : $getpaid_pages['failure_page']['content'],
144
+                    'placeholder' => __('Select a page', 'invoicing'),
145
+                    'default_content' => empty($getpaid_pages['failure_page']) ? '' : $getpaid_pages['failure_page']['content'],
146 146
                     'help-tip'    => true,
147 147
                 ),
148 148
                 'invoice_history_page' => array(
149 149
                     'id'          => 'invoice_history_page',
150
-                    'name'        => __( 'Invoice History Page', 'invoicing' ),
151
-                    'desc'        => __( 'This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing' ),
150
+                    'name'        => __('Invoice History Page', 'invoicing'),
151
+                    'desc'        => __('This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing'),
152 152
                     'type'        => 'select',
153 153
                     'options'     => $pages,
154 154
                     'class'       => 'wpi_select2',
155
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
156
-                    'default_content' => empty( $getpaid_pages['invoice_history_page'] ) ? '' : $getpaid_pages['invoice_history_page']['content'],
155
+                    'placeholder' => __('Select a page', 'invoicing'),
156
+                    'default_content' => empty($getpaid_pages['invoice_history_page']) ? '' : $getpaid_pages['invoice_history_page']['content'],
157 157
                     'help-tip'    => true,
158 158
                 ),
159 159
                 'invoice_subscription_page' => array(
160 160
                     'id'          => 'invoice_subscription_page',
161
-                    'name'        => __( 'Invoice Subscriptions Page', 'invoicing' ),
162
-                    'desc'        => __( 'This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing' ),
161
+                    'name'        => __('Invoice Subscriptions Page', 'invoicing'),
162
+                    'desc'        => __('This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing'),
163 163
                     'type'        => 'select',
164 164
                     'options'     => $pages,
165 165
                     'class'       => 'wpi_select2',
166
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
167
-                    'default_content' => empty( $getpaid_pages['invoice_subscription_page'] ) ? '' : $getpaid_pages['invoice_subscription_page']['content'],
166
+                    'placeholder' => __('Select a page', 'invoicing'),
167
+                    'default_content' => empty($getpaid_pages['invoice_subscription_page']) ? '' : $getpaid_pages['invoice_subscription_page']['content'],
168 168
                     'help-tip'    => true,
169 169
                 ),
170 170
             ),
171 171
             'currency_section' => array(
172 172
                 'currency_settings' => array(
173 173
                     'id'   => 'currency_settings',
174
-                    'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>',
174
+                    'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>',
175 175
                     'desc' => '',
176 176
                     'type' => 'header',
177 177
                 ),
178 178
                 'currency' => array(
179 179
                     'id'      => 'currency',
180
-                    'name'    => __( 'Currency', 'invoicing' ),
181
-                    'desc'    => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ),
180
+                    'name'    => __('Currency', 'invoicing'),
181
+                    'desc'    => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'),
182 182
                     'type'    => 'select',
183 183
                     'class'       => 'wpi_select2',
184 184
                     'options' => $currency_code_options,
185 185
                 ),
186 186
                 'currency_position' => array(
187 187
                     'id'      => 'currency_position',
188
-                    'name'    => __( 'Currency Position', 'invoicing' ),
189
-                    'desc'    => __( 'Choose the location of the currency sign.', 'invoicing' ),
188
+                    'name'    => __('Currency Position', 'invoicing'),
189
+                    'desc'    => __('Choose the location of the currency sign.', 'invoicing'),
190 190
                     'type'    => 'select',
191 191
                     'class'   => 'wpi_select2',
192 192
                     'options'  => array(
193
-                        'left'        => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')',
194
-                        'right'       => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')',
195
-                        'left_space'  => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')',
196
-                        'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')'
193
+                        'left'        => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')',
194
+                        'right'       => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')',
195
+                        'left_space'  => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')',
196
+                        'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')'
197 197
                     )
198 198
                 ),
199 199
                 'thousands_separator' => array(
200 200
                     'id'   => 'thousands_separator',
201
-                    'name' => __( 'Thousands Separator', 'invoicing' ),
202
-                    'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ),
201
+                    'name' => __('Thousands Separator', 'invoicing'),
202
+                    'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'),
203 203
                     'type' => 'text',
204 204
                     'size' => 'small',
205 205
                     'std'  => ',',
206 206
                 ),
207 207
                 'decimal_separator' => array(
208 208
                     'id'   => 'decimal_separator',
209
-                    'name' => __( 'Decimal Separator', 'invoicing' ),
210
-                    'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ),
209
+                    'name' => __('Decimal Separator', 'invoicing'),
210
+                    'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'),
211 211
                     'type' => 'text',
212 212
                     'size' => 'small',
213 213
                     'std'  => '.',
214 214
                 ),
215 215
                 'decimals' => array(
216 216
                     'id'   => 'decimals',
217
-                    'name' => __( 'Number of Decimals', 'invoicing' ),
218
-                    'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ),
217
+                    'name' => __('Number of Decimals', 'invoicing'),
218
+                    'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'),
219 219
                     'type' => 'number',
220 220
                     'size' => 'small',
221 221
                     'std'  => '2',
@@ -227,21 +227,21 @@  discard block
 block discarded – undo
227 227
             'labels' => array(
228 228
                 'labels' => array(
229 229
                     'id'   => 'labels_settings',
230
-                    'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>',
230
+                    'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>',
231 231
                     'desc' => '',
232 232
                     'type' => 'header',
233 233
                 ),
234 234
                 'vat_invoice_notice_label' => array(
235 235
                     'id' => 'vat_invoice_notice_label',
236
-                    'name' => __( 'Invoice Notice Label', 'invoicing' ),
237
-                    'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ),
236
+                    'name' => __('Invoice Notice Label', 'invoicing'),
237
+                    'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'),
238 238
                     'type' => 'text',
239 239
                     'size' => 'regular',
240 240
                 ),
241 241
                 'vat_invoice_notice' => array(
242 242
                     'id' => 'vat_invoice_notice',
243
-                    'name' => __( 'Invoice notice', 'invoicing' ),
244
-                    'desc' =>   __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ),
243
+                    'name' => __('Invoice notice', 'invoicing'),
244
+                    'desc' =>   __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'),
245 245
                     'type' => 'text',
246 246
                     'size' => 'regular',
247 247
                 ),
@@ -253,22 +253,22 @@  discard block
 block discarded – undo
253 253
             'main' => array(
254 254
                 'gateway_settings' => array(
255 255
                     'id'   => 'api_header',
256
-                    'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>',
256
+                    'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>',
257 257
                     'desc' => '',
258 258
                     'type' => 'header',
259 259
                 ),
260 260
                 'gateways' => array(
261 261
                     'id'      => 'gateways',
262
-                    'name'    => __( 'Payment Gateways', 'invoicing' ),
263
-                    'desc'    => __( 'Choose the payment gateways you want to enable.', 'invoicing' ),
262
+                    'name'    => __('Payment Gateways', 'invoicing'),
263
+                    'desc'    => __('Choose the payment gateways you want to enable.', 'invoicing'),
264 264
                     'type'    => 'gateways',
265
-                    'std'     => array( 'manual'=>1 ),
265
+                    'std'     => array('manual'=>1),
266 266
                     'options' => wpinv_get_payment_gateways(),
267 267
                 ),
268 268
                 'default_gateway' => array(
269 269
                     'id'      => 'default_gateway',
270
-                    'name'    => __( 'Default Gateway', 'invoicing' ),
271
-                    'desc'    => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ),
270
+                    'name'    => __('Default Gateway', 'invoicing'),
271
+                    'desc'    => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'),
272 272
                     'type'    => 'gateway_select',
273 273
                     'std'     => 'manual',
274 274
                     'class'   => 'wpi_select2',
@@ -283,32 +283,32 @@  discard block
 block discarded – undo
283 283
             'main' => array(
284 284
                 'tax_settings' => array(
285 285
                     'id'   => 'tax_settings',
286
-                    'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>',
286
+                    'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>',
287 287
                     'type' => 'header',
288 288
                 ),
289 289
 
290 290
                 'enable_taxes' => array(
291 291
                     'id'       => 'enable_taxes',
292
-                    'name'     => __( 'Enable Taxes', 'invoicing' ),
293
-                    'desc'     => __( 'Enable tax rates and calculations.', 'invoicing' ),
292
+                    'name'     => __('Enable Taxes', 'invoicing'),
293
+                    'desc'     => __('Enable tax rates and calculations.', 'invoicing'),
294 294
                     'type'     => 'checkbox',
295 295
                     'std'      => 0,
296 296
                 ),
297 297
 
298 298
                 'tax_subtotal_rounding' => array(
299 299
                     'id'                => 'tax_subtotal_rounding',
300
-                    'name'              => __( 'Rounding', 'invoicing' ),
301
-                    'desc'              => __( 'Round tax at subtotal level, instead of rounding per tax rate', 'invoicing' ),
300
+                    'name'              => __('Rounding', 'invoicing'),
301
+                    'desc'              => __('Round tax at subtotal level, instead of rounding per tax rate', 'invoicing'),
302 302
                     'type'              => 'checkbox',
303 303
                     'std'               => 1,
304 304
                 ),
305 305
 
306 306
                 'prices_include_tax' => array(
307 307
                     'id'      => 'prices_include_tax',
308
-                    'name'    => __( 'Prices entered with tax', 'invoicing' ),
308
+                    'name'    => __('Prices entered with tax', 'invoicing'),
309 309
                     'options' => array(
310
-                        'yes' => __( 'Yes, I will enter prices inclusive of tax', 'invoicing' ),
311
-                        'no'  => __( 'No, I will enter prices exclusive of tax', 'invoicing' ),
310
+                        'yes' => __('Yes, I will enter prices inclusive of tax', 'invoicing'),
311
+                        'no'  => __('No, I will enter prices exclusive of tax', 'invoicing'),
312 312
                     ),
313 313
                     'type'    => 'select',
314 314
                     'std'     => 'no',
@@ -316,10 +316,10 @@  discard block
 block discarded – undo
316 316
 
317 317
                 'tax_base'              => array(
318 318
                     'id'                => 'tax_base',
319
-                    'name'              => __( 'Calculate tax based on', 'invoicing' ),
319
+                    'name'              => __('Calculate tax based on', 'invoicing'),
320 320
                     'options'           => array(
321
-                        'billing'       => __( 'Customer billing address', 'invoicing' ),
322
-                        'base'          => __( 'Shop base address', 'invoicing' ),
321
+                        'billing'       => __('Customer billing address', 'invoicing'),
322
+                        'base'          => __('Shop base address', 'invoicing'),
323 323
                     ),
324 324
                     'type'              => 'select',
325 325
                     'std'               => 'billing',
@@ -327,10 +327,10 @@  discard block
 block discarded – undo
327 327
 
328 328
                 'tax_display_totals'    => array(
329 329
                     'id'                => 'tax_display_totals',
330
-                    'name'              => __( 'Display tax totals', 'invoicing' ),
330
+                    'name'              => __('Display tax totals', 'invoicing'),
331 331
                     'options'           => array(
332
-                        'single'        => __( 'As a single total', 'invoicing' ),
333
-                        'individual'    => __( 'As individual tax rates', 'invoicing' ),
332
+                        'single'        => __('As a single total', 'invoicing'),
333
+                        'individual'    => __('As individual tax rates', 'invoicing'),
334 334
                     ),
335 335
                     'type'              => 'select',
336 336
                     'std'               => 'individual',
@@ -338,8 +338,8 @@  discard block
 block discarded – undo
338 338
 
339 339
                 'tax_rate' => array(
340 340
                     'id'   => 'tax_rate',
341
-                    'name' => __( 'Fallback Tax Rate', 'invoicing' ),
342
-                    'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ),
341
+                    'name' => __('Fallback Tax Rate', 'invoicing'),
342
+                    'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'),
343 343
                     'type' => 'number',
344 344
                     'size' => 'small',
345 345
                     'min'  => '0',
@@ -351,8 +351,8 @@  discard block
 block discarded – undo
351 351
             'rates' => array(
352 352
                 'tax_rates' => array(
353 353
                     'id'   => 'tax_rates',
354
-                    'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>',
355
-                    'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ),
354
+                    'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>',
355
+                    'desc' => __('Enter tax rates for specific regions.', 'invoicing'),
356 356
                     'type' => 'tax_rates',
357 357
                 ),
358 358
             ),
@@ -361,45 +361,45 @@  discard block
 block discarded – undo
361 361
 
362 362
                 'vat_company_name' => array(
363 363
                     'id' => 'vat_company_name',
364
-                    'name' => __( 'Company Name', 'invoicing' ),
365
-                    'desc' => wp_sprintf(__( 'Verify your company name and  VAT number on the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ),
364
+                    'name' => __('Company Name', 'invoicing'),
365
+                    'desc' => wp_sprintf(__('Verify your company name and  VAT number on the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'),
366 366
                     'type' => 'text',
367 367
                     'size' => 'regular',
368 368
                 ),
369 369
 
370 370
                 'vat_number' => array(
371 371
                     'id'   => 'vat_number',
372
-                    'name' => __( 'VAT Number', 'invoicing' ),
373
-                    'desc' => __( 'Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing' ),
372
+                    'name' => __('VAT Number', 'invoicing'),
373
+                    'desc' => __('Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing'),
374 374
                     'type' => 'text',
375 375
                     'size' => 'regular',
376 376
                 ),
377 377
 
378 378
                 'vat_prevent_b2c_purchase' => array(
379 379
                     'id' => 'vat_prevent_b2c_purchase',
380
-                    'name' => __( 'Prevent B2C Sales', 'invoicing' ),
381
-                    'desc' => __( 'Require everyone in the EU to provide a VAT number.', 'invoicing' ),
380
+                    'name' => __('Prevent B2C Sales', 'invoicing'),
381
+                    'desc' => __('Require everyone in the EU to provide a VAT number.', 'invoicing'),
382 382
                     'type' => 'checkbox'
383 383
                 ),
384 384
 
385 385
                 'validate_vat_number' => array(
386 386
                     'id'   => 'validate_vat_number',
387
-                    'name' => __( 'Validate VAT Number', 'invoicing' ),
388
-                    'desc' => __( 'Validate VAT numbers with VIES.', 'invoicing' ),
387
+                    'name' => __('Validate VAT Number', 'invoicing'),
388
+                    'desc' => __('Validate VAT numbers with VIES.', 'invoicing'),
389 389
                     'type' => 'checkbox'
390 390
                 ),
391 391
 
392 392
                 'vat_same_country_rule' => array(
393 393
                     'id'          => 'vat_same_country_rule',
394
-                    'name'        => __( 'Same Country Rule', 'invoicing' ),
395
-                    'desc'        => __( 'What should happen if a customer is from the same country as your business?', 'invoicing' ),
394
+                    'name'        => __('Same Country Rule', 'invoicing'),
395
+                    'desc'        => __('What should happen if a customer is from the same country as your business?', 'invoicing'),
396 396
                     'type'        => 'select',
397 397
                     'options'     => array(
398
-                        'no'        => __( 'Do not charge tax', 'invoicing' ),
399
-                        'always'    => __( 'Charge tax unless vat number is validated', 'invoicing' ),
400
-                        'vat_too'   => __( 'Charge tax even if vat number is validated', 'invoicing' )
398
+                        'no'        => __('Do not charge tax', 'invoicing'),
399
+                        'always'    => __('Charge tax unless vat number is validated', 'invoicing'),
400
+                        'vat_too'   => __('Charge tax even if vat number is validated', 'invoicing')
401 401
                     ),
402
-                    'placeholder' => __( 'Select an option', 'invoicing' ),
402
+                    'placeholder' => __('Select an option', 'invoicing'),
403 403
                     'std'         => 'vat_too',
404 404
                 ),
405 405
 
@@ -413,66 +413,66 @@  discard block
 block discarded – undo
413 413
             'main' => array(
414 414
                 'email_settings_header' => array(
415 415
                     'id'   => 'email_settings_header',
416
-                    'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>',
416
+                    'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>',
417 417
                     'type' => 'header',
418 418
                 ),
419 419
                 'email_from_name' => array(
420 420
                     'id'   => 'email_from_name',
421
-                    'name' => __( 'From Name', 'invoicing' ),
422
-                    'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ),
423
-                    'std' => esc_attr( get_bloginfo( 'name', 'display' ) ),
421
+                    'name' => __('From Name', 'invoicing'),
422
+                    'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'),
423
+                    'std' => esc_attr(get_bloginfo('name', 'display')),
424 424
                     'type' => 'text',
425 425
                 ),
426 426
                 'email_from' => array(
427 427
                     'id'   => 'email_from',
428
-                    'name' => __( 'From Email', 'invoicing' ),
429
-                    'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close),
430
-                    'std' => get_option( 'admin_email' ),
428
+                    'name' => __('From Email', 'invoicing'),
429
+                    'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close),
430
+                    'std' => get_option('admin_email'),
431 431
                     'type' => 'text',
432 432
                 ),
433 433
                 'admin_email' => array(
434 434
                     'id'   => 'admin_email',
435
-                    'name' => __( 'Admin Email', 'invoicing' ),
436
-                    'desc' => __( 'Where should we send admin notifications? This will is also act as the "reply-to" address for invoice emails', 'invoicing' ),
437
-                    'std' => get_option( 'admin_email' ),
435
+                    'name' => __('Admin Email', 'invoicing'),
436
+                    'desc' => __('Where should we send admin notifications? This will is also act as the "reply-to" address for invoice emails', 'invoicing'),
437
+                    'std' => get_option('admin_email'),
438 438
                     'type' => 'text',
439 439
                 ),
440 440
                 'skip_email_free_invoice' => array(
441 441
                     'id'   => 'skip_email_free_invoice',
442
-                    'name' => __( 'Skip Free Invoices', 'invoicing' ),
443
-                    'desc' => __( 'Check this to disable sending emails for free invoices.', 'invoicing' ),
442
+                    'name' => __('Skip Free Invoices', 'invoicing'),
443
+                    'desc' => __('Check this to disable sending emails for free invoices.', 'invoicing'),
444 444
                     'type' => 'checkbox',
445 445
                     'std'  => false,
446 446
                 ),
447 447
                 'overdue_settings_header' => array(
448 448
                     'id'   => 'overdue_settings_header',
449
-                    'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>',
449
+                    'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>',
450 450
                     'type' => 'header',
451 451
                 ),
452 452
                 'overdue_active' => array(
453 453
                     'id'   => 'overdue_active',
454
-                    'name' => __( 'Enable Due Date', 'invoicing' ),
455
-                    'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ),
454
+                    'name' => __('Enable Due Date', 'invoicing'),
455
+                    'desc' => __('Check this to enable due date option for invoices.', 'invoicing'),
456 456
                     'type' => 'checkbox',
457 457
                     'std'  => false,
458 458
                 ),
459 459
                 'email_template_header' => array(
460 460
                     'id'   => 'email_template_header',
461
-                    'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>',
461
+                    'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>',
462 462
                     'type' => 'header',
463 463
                 ),
464 464
                 'email_header_image' => array(
465 465
                     'id'   => 'email_header_image',
466
-                    'name' => __( 'Header Image', 'invoicing' ),
467
-                    'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ),
466
+                    'name' => __('Header Image', 'invoicing'),
467
+                    'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'),
468 468
                     'std' => '',
469 469
                     'type' => 'text',
470 470
                 ),
471 471
                 'email_footer_text' => array(
472 472
                     'id'   => 'email_footer_text',
473
-                    'name' => __( 'Footer Text', 'invoicing' ),
474
-                    'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ),
475
-                    'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GetPaid', 'invoicing' ),
473
+                    'name' => __('Footer Text', 'invoicing'),
474
+                    'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'),
475
+                    'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GetPaid', 'invoicing'),
476 476
                     'type' => 'textarea',
477 477
                     'class' => 'regular-text',
478 478
                     'rows' => 2,
@@ -480,29 +480,29 @@  discard block
 block discarded – undo
480 480
                 ),
481 481
                 'email_base_color' => array(
482 482
                     'id'   => 'email_base_color',
483
-                    'name' => __( 'Base Color', 'invoicing' ),
484
-                    'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ),
483
+                    'name' => __('Base Color', 'invoicing'),
484
+                    'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'),
485 485
                     'std' => '#557da2',
486 486
                     'type' => 'color',
487 487
                 ),
488 488
                 'email_background_color' => array(
489 489
                     'id'   => 'email_background_color',
490
-                    'name' => __( 'Background Color', 'invoicing' ),
491
-                    'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ),
490
+                    'name' => __('Background Color', 'invoicing'),
491
+                    'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'),
492 492
                     'std' => '#f5f5f5',
493 493
                     'type' => 'color',
494 494
                 ),
495 495
                 'email_body_background_color' => array(
496 496
                     'id'   => 'email_body_background_color',
497
-                    'name' => __( 'Body Background Color', 'invoicing' ),
498
-                    'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ),
497
+                    'name' => __('Body Background Color', 'invoicing'),
498
+                    'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'),
499 499
                     'std' => '#fdfdfd',
500 500
                     'type' => 'color',
501 501
                 ),
502 502
                 'email_text_color' => array(
503 503
                     'id'   => 'email_text_color',
504
-                    'name' => __( 'Body Text Color', 'invoicing' ),
505
-                    'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ),
504
+                    'name' => __('Body Text Color', 'invoicing'),
505
+                    'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'),
506 506
                     'std' => '#505050',
507 507
                     'type' => 'color',
508 508
                 ),
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
     ),
518 518
 
519 519
     // Integrations.
520
-    'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'settings', 'id' ),
520
+    'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'settings', 'id'),
521 521
 
522 522
     /** Privacy Settings */
523 523
     'privacy' => apply_filters('wpinv_settings_privacy',
@@ -525,17 +525,17 @@  discard block
 block discarded – undo
525 525
             'main' => array(
526 526
                 'invoicing_privacy_policy_settings' => array(
527 527
                     'id'   => 'invoicing_privacy_policy_settings',
528
-                    'name' => '<h3>' . __( 'Privacy Policy', 'invoicing' ) . '</h3>',
528
+                    'name' => '<h3>' . __('Privacy Policy', 'invoicing') . '</h3>',
529 529
                     'type' => 'header',
530 530
                 ),
531 531
                 'privacy_page' => array(
532 532
                     'id'          => 'privacy_page',
533
-                    'name'        => __( 'Privacy Page', 'invoicing' ),
534
-                    'desc'        => __( 'If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing' ),
533
+                    'name'        => __('Privacy Page', 'invoicing'),
534
+                    'desc'        => __('If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing'),
535 535
                     'type'        => 'select',
536
-                    'options'     => wpinv_get_pages( true,  __( 'Select a page', 'invoicing' )),
536
+                    'options'     => wpinv_get_pages(true, __('Select a page', 'invoicing')),
537 537
                     'class'       => 'wpi_select2',
538
-                    'placeholder' => __( 'Select a page', 'invoicing' ),
538
+                    'placeholder' => __('Select a page', 'invoicing'),
539 539
                 ),
540 540
             ),
541 541
         )
@@ -546,19 +546,19 @@  discard block
 block discarded – undo
546 546
             'main' => array(
547 547
                 'invoice_number_format_settings' => array(
548 548
                     'id'   => 'invoice_number_format_settings',
549
-                    'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>',
549
+                    'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>',
550 550
                     'type' => 'header',
551 551
                 ),
552 552
                 'sequential_invoice_number' => array(
553 553
                     'id'   => 'sequential_invoice_number',
554
-                    'name' => __( 'Sequential Invoice Numbers', 'invoicing' ),
555
-                    'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing' ) . $reset_number,
554
+                    'name' => __('Sequential Invoice Numbers', 'invoicing'),
555
+                    'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing') . $reset_number,
556 556
                     'type' => 'checkbox',
557 557
                 ),
558 558
                 'invoice_sequence_start' => array(
559 559
                     'id'   => 'invoice_sequence_start',
560
-                    'name' => __( 'Sequential Starting Number', 'invoicing' ),
561
-                    'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number,
560
+                    'name' => __('Sequential Starting Number', 'invoicing'),
561
+                    'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number,
562 562
                     'type' => 'number',
563 563
                     'size' => 'small',
564 564
                     'std'  => '1',
@@ -566,8 +566,8 @@  discard block
 block discarded – undo
566 566
                 ),
567 567
                 'invoice_number_padd' => array(
568 568
                     'id'      => 'invoice_number_padd',
569
-                    'name'    => __( 'Minimum Digits', 'invoicing' ),
570
-                    'desc'    => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ),
569
+                    'name'    => __('Minimum Digits', 'invoicing'),
570
+                    'desc'    => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'),
571 571
                     'type'    => 'select',
572 572
                     'options' => $invoice_number_padd_options,
573 573
                     'std'     => 5,
@@ -575,8 +575,8 @@  discard block
 block discarded – undo
575 575
                 ),
576 576
                 'invoice_number_prefix' => array(
577 577
                     'id' => 'invoice_number_prefix',
578
-                    'name' => __( 'Invoice Number Prefix', 'invoicing' ),
579
-                    'desc' => __( 'Prefix for all invoice numbers. Ex: INV-', 'invoicing' ),
578
+                    'name' => __('Invoice Number Prefix', 'invoicing'),
579
+                    'desc' => __('Prefix for all invoice numbers. Ex: INV-', 'invoicing'),
580 580
                     'type' => 'text',
581 581
                     'size' => 'regular',
582 582
                     'std' => 'INV-',
@@ -584,46 +584,46 @@  discard block
 block discarded – undo
584 584
                 ),
585 585
                 'invoice_number_postfix' => array(
586 586
                     'id' => 'invoice_number_postfix',
587
-                    'name' => __( 'Invoice Number Postfix', 'invoicing' ),
588
-                    'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ),
587
+                    'name' => __('Invoice Number Postfix', 'invoicing'),
588
+                    'desc' => __('Postfix for all invoice numbers.', 'invoicing'),
589 589
                     'type' => 'text',
590 590
                     'size' => 'regular',
591 591
                     'std' => ''
592 592
                 ),
593 593
                 'checkout_settings' => array(
594 594
                     'id'   => 'checkout_settings',
595
-                    'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>',
595
+                    'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>',
596 596
                     'type' => 'header',
597 597
                 ),
598 598
                 'disable_new_user_emails' => array(
599 599
                     'id'   => 'disable_new_user_emails',
600
-                    'name' => __( 'Disable new user emails', 'invoicing' ),
601
-                    'desc' => __( 'Do not send an email to customers when a new user account is created for them.', 'invoicing' ),
600
+                    'name' => __('Disable new user emails', 'invoicing'),
601
+                    'desc' => __('Do not send an email to customers when a new user account is created for them.', 'invoicing'),
602 602
                     'type' => 'checkbox',
603 603
                 ),
604 604
                 'login_to_checkout' => array(
605 605
                     'id'   => 'login_to_checkout',
606
-                    'name' => __( 'Require Login To Checkout', 'invoicing' ),
607
-                    'desc' => __( 'If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing' ),
606
+                    'name' => __('Require Login To Checkout', 'invoicing'),
607
+                    'desc' => __('If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing'),
608 608
                     'type' => 'checkbox',
609 609
                 ),
610 610
                 'maxmind_license_key' => array(
611 611
                     'id'   => 'maxmind_license_key',
612
-                    'name' => __( 'MaxMind License Key', 'invoicing' ),
612
+                    'name' => __('MaxMind License Key', 'invoicing'),
613 613
                     'type' => 'text',
614 614
                     'size' => 'regular',
615
-                    'desc' => __( "Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing' ) . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __( 'How to generate a free license key.', 'invoicing' ) . '</a>',
615
+                    'desc' => __("Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing') . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __('How to generate a free license key.', 'invoicing') . '</a>',
616 616
                 ),
617 617
 
618 618
                 'uninstall_settings' => array(
619 619
                     'id'   => 'uninstall_settings',
620
-                    'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>',
620
+                    'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>',
621 621
                     'type' => 'header',
622 622
                 ),
623 623
                 'remove_data_on_unistall' => array(
624 624
                     'id'   => 'remove_data_on_unistall',
625
-                    'name' => __( 'Remove Data on Uninstall?', 'invoicing' ),
626
-                    'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ),
625
+                    'name' => __('Remove Data on Uninstall?', 'invoicing'),
626
+                    'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'),
627 627
                     'type' => 'checkbox',
628 628
                     'std'  => ''
629 629
                 ),
@@ -632,13 +632,13 @@  discard block
 block discarded – undo
632 632
             'custom-css' => array(
633 633
                 'css_settings' => array(
634 634
                     'id'   => 'css_settings',
635
-                    'name' => '<h3>' . __( 'Custom CSS', 'invoicing' ) . '</h3>',
635
+                    'name' => '<h3>' . __('Custom CSS', 'invoicing') . '</h3>',
636 636
                     'type' => 'header',
637 637
                 ),
638 638
                 'template_custom_css' => array(
639 639
                     'id' => 'template_custom_css',
640
-                    'name' => __( 'Invoice Template CSS', 'invoicing' ),
641
-                    'desc' => __( 'Add CSS to modify appearance of the print invoice page.', 'invoicing' ),
640
+                    'name' => __('Invoice Template CSS', 'invoicing'),
641
+                    'desc' => __('Add CSS to modify appearance of the print invoice page.', 'invoicing'),
642 642
                     'type' => 'textarea',
643 643
                     'class'=> 'regular-text',
644 644
                     'rows' => 10,
@@ -652,8 +652,8 @@  discard block
 block discarded – undo
652 652
             'main' => array(
653 653
                 'tool_settings' => array(
654 654
                     'id'   => 'tool_settings',
655
-                    'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>',
656
-                    'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ),
655
+                    'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>',
656
+                    'desc' => __('Invoicing diagnostic tools', 'invoicing'),
657 657
                     'type' => 'tools',
658 658
                 ),
659 659
             ),
Please login to merge, or discard this patch.
includes/admin/html-admin-page-addons.php 3 patches
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 if ( ! defined( 'ABSPATH' ) ) {
7
-	exit;
7
+    exit;
8 8
 }
9 9
 add_ThickBox();
10 10
 ?>
@@ -14,18 +14,18 @@  discard block
 block discarded – undo
14 14
 	<?php if ( $tabs ){ ?>
15 15
 		<nav class="nav-tab-wrapper wpi-nav-tab-wrapper">
16 16
 			<?php
17
-			foreach ( $tabs as $name => $label ) {
18
-				echo '<a href="' . admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>';
19
-			}
20
-			do_action( 'wpi_addons_tabs' );
21
-			?>
17
+            foreach ( $tabs as $name => $label ) {
18
+                echo '<a href="' . admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>';
19
+            }
20
+            do_action( 'wpi_addons_tabs' );
21
+            ?>
22 22
 		</nav>
23 23
 
24 24
 		<?php
25 25
 
26
-		if($current_tab == 'membership'){
26
+        if($current_tab == 'membership'){
27 27
 
28
-			?>
28
+            ?>
29 29
 
30 30
 			<div class="wpi-membership-tab-conatiner">
31 31
 				<div class="membership-content">
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 					<h2><?php _e("Have a membership key?","invoicing");?></h2>
37 37
 					<p>
38 38
 						<?php
39
-						$wpeu_admin = new External_Updates_Admin('wpinvoicing.com','1');
40
-						echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership',array(95, 106, 108,12351));
41
-						?>
39
+                        $wpeu_admin = new External_Updates_Admin('wpinvoicing.com','1');
40
+                        echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership',array(95, 106, 108,12351));
41
+                        ?>
42 42
 					</p>
43 43
 				<?php }?>
44 44
 
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 							<div class="feature-list">
49 49
 								<ul>
50 50
 									<?php
51
-									$addon_obj = new WPInv_Admin_Addons();
52
-									if ($addons = $addon_obj->get_section_data( 'addons' ) ) {
53
-										foreach ( $addons as $addon ) {
54
-											echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>';
55
-										}
56
-									}
57
-									?>
51
+                                    $addon_obj = new WPInv_Admin_Addons();
52
+                                    if ($addons = $addon_obj->get_section_data( 'addons' ) ) {
53
+                                        foreach ( $addons as $addon ) {
54
+                                            echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>';
55
+                                        }
56
+                                    }
57
+                                    ?>
58 58
 									</ul>
59 59
 
60 60
 									<div class="feature-cta">
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
 									<h3><?php _e("Included Gateways:","invoicing");?></h3>
66 66
 									<ul>
67 67
 										<?php
68
-										if ($addons = $addon_obj->get_section_data( 'gateways' ) ) {
69
-											foreach ( $addons as $addon ) {
70
-												echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>';
71
-											}
72
-										}
73
-										?>
68
+                                        if ($addons = $addon_obj->get_section_data( 'gateways' ) ) {
69
+                                            foreach ( $addons as $addon ) {
70
+                                                echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>';
71
+                                            }
72
+                                        }
73
+                                        ?>
74 74
 								</ul>
75 75
 							</div>
76 76
 
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 						<div class="testimonial-content">
82 82
 							<div class="t-image">
83 83
 								<?php
84
-									echo '<img src="' . plugins_url( 'images/t-image2.png', dirname(__FILE__) ) . '" > ';
85
-								?>
84
+                                    echo '<img src="' . plugins_url( 'images/t-image2.png', dirname(__FILE__) ) . '" > ';
85
+                                ?>
86 86
 							</div>
87 87
 							<div class="t-content">
88 88
 								<p>
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 						<div class="testimonial-content">
102 102
 							<div class="t-image">
103 103
 								<?php
104
-									echo '<img src="' . plugins_url( 'images/t-image1.png', dirname(__FILE__) ) . '" > ';
105
-								?>
104
+                                    echo '<img src="' . plugins_url( 'images/t-image1.png', dirname(__FILE__) ) . '" > ';
105
+                                ?>
106 106
 							</div>
107 107
 							<div class="t-content">
108 108
 								<p>
@@ -126,21 +126,21 @@  discard block
 block discarded – undo
126 126
 			</div>
127 127
 		</div>
128 128
 			<?php
129
-		}else{
130
-			$installed_plugins = get_plugins();
129
+        }else{
130
+            $installed_plugins = get_plugins();
131 131
             $addon_obj = new WPInv_Admin_Addons();
132
-			if ($addons = $addon_obj->get_section_data( $current_tab ) ) :
133
-				//print_r($addons);
134
-				?>
132
+            if ($addons = $addon_obj->get_section_data( $current_tab ) ) :
133
+                //print_r($addons);
134
+                ?>
135 135
 				<ul class="wpi-products"><?php foreach ( $addons as $addon ) :
136 136
                         if(965==$addon->info->id){continue;}// don't show quote add on
137
-						?><li class="wpi-product">
137
+                        ?><li class="wpi-product">
138 138
 								<div class="wpi-product-title">
139 139
 									<h3><?php
140
-										if ( ! empty( $addon->info->excerpt) ){
141
-											echo wpi_help_tip( $addon->info->excerpt );
142
-										}
143
-										echo esc_html( $addon->info->title ); ?></h3>
140
+                                        if ( ! empty( $addon->info->excerpt) ){
141
+                                            echo wpi_help_tip( $addon->info->excerpt );
142
+                                        }
143
+                                        echo esc_html( $addon->info->title ); ?></h3>
144 144
 								</div>
145 145
 
146 146
 								<span class="wpi-product-image">
@@ -148,32 +148,32 @@  discard block
 block discarded – undo
148 148
 										<img src="<?php echo esc_attr( $addon->info->thumbnail ); ?>"/>
149 149
 									<?php endif;
150 150
 
151
-									if ( 'stripe-payment-gateway' == $addon->info->slug ) {
152
-										$addon->info->slug = 'getpaid-stripe-payments';
153
-										$addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/';
154
-									}
155
-
156
-									if(isset($addon->info->link) && substr( $addon->info->link, 0, 21 ) === "https://wordpress.org"){
157
-										echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&width=770&height=660&TB_iframe=true" class="thickbox" >';
158
-										echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
159
-										echo '</a>';
160
-									}elseif(isset($addon->info->link) && ( substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com" || substr( $addon->info->link, 0, 21 ) === "https://wpgetpaid.com" ) ){
161
-										if(defined('WP_EASY_UPDATES_ACTIVE')){
162
-											$url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpgetpaid.com&TB_iframe=true');
163
-										}else{
164
-											// if installed show activation link
165
-											if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){
166
-												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation';
167
-											}else{
168
-												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external';
169
-											}
170
-										}
171
-										echo '<a href="'.$url.'" class="thickbox">';
172
-										echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
173
-										echo '</a>';
174
-									}
175
-
176
-									?>
151
+                                    if ( 'stripe-payment-gateway' == $addon->info->slug ) {
152
+                                        $addon->info->slug = 'getpaid-stripe-payments';
153
+                                        $addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/';
154
+                                    }
155
+
156
+                                    if(isset($addon->info->link) && substr( $addon->info->link, 0, 21 ) === "https://wordpress.org"){
157
+                                        echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&width=770&height=660&TB_iframe=true" class="thickbox" >';
158
+                                        echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
159
+                                        echo '</a>';
160
+                                    }elseif(isset($addon->info->link) && ( substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com" || substr( $addon->info->link, 0, 21 ) === "https://wpgetpaid.com" ) ){
161
+                                        if(defined('WP_EASY_UPDATES_ACTIVE')){
162
+                                            $url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpgetpaid.com&TB_iframe=true');
163
+                                        }else{
164
+                                            // if installed show activation link
165
+                                            if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){
166
+                                                $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation';
167
+                                            }else{
168
+                                                $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external';
169
+                                            }
170
+                                        }
171
+                                        echo '<a href="'.$url.'" class="thickbox">';
172
+                                        echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
173
+                                        echo '</a>';
174
+                                    }
175
+
176
+                                    ?>
177 177
 
178 178
 								</span>
179 179
 
@@ -181,15 +181,15 @@  discard block
 block discarded – undo
181 181
 								<span class="wpi-product-button">
182 182
 									<?php
183 183
                                     $addon_obj->output_button( $addon );
184
-									?>
184
+                                    ?>
185 185
 								</span>
186 186
 
187 187
 								<span class="wpi-price"><?php //print_r($addon); //echo wp_kses_post( $addon->price ); ?></span></li><?php endforeach; ?></ul>
188 188
 			<?php endif;
189
-		}
189
+        }
190 190
 
191
-	}
192
-	?>
191
+    }
192
+    ?>
193 193
 
194 194
 
195 195
 	<div class="clearfix" ></div>
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 			<input class="wpeu-licence-key" type="text" placeholder="<?php _e("Enter your licence key",'invoicing');?>"> <button class="button-primary wpeu-licence-popup-button" ><?php _e("Install",'invoicing');?></button>
209 209
 			<br>
210 210
 			<?php
211
-			echo sprintf( __('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">','</a>','<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">','</a>' );
212
-			?>
211
+            echo sprintf( __('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">','</a>','<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">','</a>' );
212
+            ?>
213 213
 		</span>
214 214
 	</div>
215 215
 
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Admin View: Page - Addons
4 4
  *
5 5
  */
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if (!defined('ABSPATH')) {
7 7
 	exit;
8 8
 }
9 9
 add_ThickBox();
@@ -11,19 +11,19 @@  discard block
 block discarded – undo
11 11
 <div class="wrap wpi_addons_wrap">
12 12
 	<h1><?php echo get_admin_page_title(); ?></h1>
13 13
 
14
-	<?php if ( $tabs ){ ?>
14
+	<?php if ($tabs) { ?>
15 15
 		<nav class="nav-tab-wrapper wpi-nav-tab-wrapper">
16 16
 			<?php
17
-			foreach ( $tabs as $name => $label ) {
18
-				echo '<a href="' . admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>';
17
+			foreach ($tabs as $name => $label) {
18
+				echo '<a href="' . admin_url('admin.php?page=wpi-addons&tab=' . $name) . '" class="nav-tab ' . ($current_tab == $name ? 'nav-tab-active' : '') . '">' . $label . '</a>';
19 19
 			}
20
-			do_action( 'wpi_addons_tabs' );
20
+			do_action('wpi_addons_tabs');
21 21
 			?>
22 22
 		</nav>
23 23
 
24 24
 		<?php
25 25
 
26
-		if($current_tab == 'membership'){
26
+		if ($current_tab == 'membership') {
27 27
 
28 28
 			?>
29 29
 
@@ -32,42 +32,42 @@  discard block
 block discarded – undo
32 32
 <!--
33 33
 				<h2>With our WPInvoicing Membership you get access to all our products!</h2>
34 34
 				<p><a class="button button-primary" href="https://wpinvoicing.com/downloads/membership/">View Memberships</a></p>-->
35
-				<?php if(defined('WP_EASY_UPDATES_ACTIVE')){?>
36
-					<h2><?php _e("Have a membership key?","invoicing");?></h2>
35
+				<?php if (defined('WP_EASY_UPDATES_ACTIVE')) {?>
36
+					<h2><?php _e("Have a membership key?", "invoicing"); ?></h2>
37 37
 					<p>
38 38
 						<?php
39
-						$wpeu_admin = new External_Updates_Admin('wpinvoicing.com','1');
40
-						echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership',array(95, 106, 108,12351));
39
+						$wpeu_admin = new External_Updates_Admin('wpinvoicing.com', '1');
40
+						echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership', array(95, 106, 108, 12351));
41 41
 						?>
42 42
 					</p>
43 43
 				<?php }?>
44 44
 
45 45
 				<div class="membership-cta-contet">
46 46
 					<div class="main-cta">
47
-							<h2><?php _e("Membership benefits Include:","invoicing");?></h2>
47
+							<h2><?php _e("Membership benefits Include:", "invoicing"); ?></h2>
48 48
 							<div class="feature-list">
49 49
 								<ul>
50 50
 									<?php
51 51
 									$addon_obj = new WPInv_Admin_Addons();
52
-									if ($addons = $addon_obj->get_section_data( 'addons' ) ) {
53
-										foreach ( $addons as $addon ) {
54
-											echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>';
52
+									if ($addons = $addon_obj->get_section_data('addons')) {
53
+										foreach ($addons as $addon) {
54
+											echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html($addon->info->title) . '</li>';
55 55
 										}
56 56
 									}
57 57
 									?>
58 58
 									</ul>
59 59
 
60 60
 									<div class="feature-cta">
61
-										<h3><?php _e("Membership Starts from","invoicing");?></h3>
61
+										<h3><?php _e("Membership Starts from", "invoicing"); ?></h3>
62 62
 										<h4>$99</h4>
63
-										<a href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php _e("Buy Membership","invoicing");?></a>
63
+										<a href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php _e("Buy Membership", "invoicing"); ?></a>
64 64
 									</div>
65
-									<h3><?php _e("Included Gateways:","invoicing");?></h3>
65
+									<h3><?php _e("Included Gateways:", "invoicing"); ?></h3>
66 66
 									<ul>
67 67
 										<?php
68
-										if ($addons = $addon_obj->get_section_data( 'gateways' ) ) {
69
-											foreach ( $addons as $addon ) {
70
-												echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>';
68
+										if ($addons = $addon_obj->get_section_data('gateways')) {
69
+											foreach ($addons as $addon) {
70
+												echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html($addon->info->title) . '</li>';
71 71
 											}
72 72
 										}
73 73
 										?>
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 						<div class="testimonial-content">
82 82
 							<div class="t-image">
83 83
 								<?php
84
-									echo '<img src="' . plugins_url( 'images/t-image2.png', dirname(__FILE__) ) . '" > ';
84
+									echo '<img src="' . plugins_url('images/t-image2.png', dirname(__FILE__)) . '" > ';
85 85
 								?>
86 86
 							</div>
87 87
 							<div class="t-content">
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 						<div class="testimonial-content">
102 102
 							<div class="t-image">
103 103
 								<?php
104
-									echo '<img src="' . plugins_url( 'images/t-image1.png', dirname(__FILE__) ) . '" > ';
104
+									echo '<img src="' . plugins_url('images/t-image1.png', dirname(__FILE__)) . '" > ';
105 105
 								?>
106 106
 							</div>
107 107
 							<div class="t-content">
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
 						</div>
118 118
 					</div>
119 119
 					<div class="member-footer">
120
-						<a class="footer-btn" href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php _e("Buy Membership","invoicing");?></a>
121
-						<a class="footer-link" href="post-new.php?post_type=wpi_invoice"><?php _e("Create Invoice","invoicing");?></a>
120
+						<a class="footer-btn" href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php _e("Buy Membership", "invoicing"); ?></a>
121
+						<a class="footer-link" href="post-new.php?post_type=wpi_invoice"><?php _e("Create Invoice", "invoicing"); ?></a>
122 122
 					</div>
123 123
 				</div>
124 124
 
@@ -126,50 +126,50 @@  discard block
 block discarded – undo
126 126
 			</div>
127 127
 		</div>
128 128
 			<?php
129
-		}else{
129
+		} else {
130 130
 			$installed_plugins = get_plugins();
131 131
             $addon_obj = new WPInv_Admin_Addons();
132
-			if ($addons = $addon_obj->get_section_data( $current_tab ) ) :
132
+			if ($addons = $addon_obj->get_section_data($current_tab)) :
133 133
 				//print_r($addons);
134 134
 				?>
135
-				<ul class="wpi-products"><?php foreach ( $addons as $addon ) :
136
-                        if(965==$addon->info->id){continue;}// don't show quote add on
135
+				<ul class="wpi-products"><?php foreach ($addons as $addon) :
136
+                        if (965 == $addon->info->id) {continue; }// don't show quote add on
137 137
 						?><li class="wpi-product">
138 138
 								<div class="wpi-product-title">
139 139
 									<h3><?php
140
-										if ( ! empty( $addon->info->excerpt) ){
141
-											echo wpi_help_tip( $addon->info->excerpt );
140
+										if (!empty($addon->info->excerpt)) {
141
+											echo wpi_help_tip($addon->info->excerpt);
142 142
 										}
143
-										echo esc_html( $addon->info->title ); ?></h3>
143
+										echo esc_html($addon->info->title); ?></h3>
144 144
 								</div>
145 145
 
146 146
 								<span class="wpi-product-image">
147
-									<?php if ( ! empty( $addon->info->thumbnail) ) : ?>
148
-										<img src="<?php echo esc_attr( $addon->info->thumbnail ); ?>"/>
147
+									<?php if (!empty($addon->info->thumbnail)) : ?>
148
+										<img src="<?php echo esc_attr($addon->info->thumbnail); ?>"/>
149 149
 									<?php endif;
150 150
 
151
-									if ( 'stripe-payment-gateway' == $addon->info->slug ) {
151
+									if ('stripe-payment-gateway' == $addon->info->slug) {
152 152
 										$addon->info->slug = 'getpaid-stripe-payments';
153 153
 										$addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/';
154 154
 									}
155 155
 
156
-									if(isset($addon->info->link) && substr( $addon->info->link, 0, 21 ) === "https://wordpress.org"){
157
-										echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&width=770&height=660&TB_iframe=true" class="thickbox" >';
158
-										echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
156
+									if (isset($addon->info->link) && substr($addon->info->link, 0, 21) === "https://wordpress.org") {
157
+										echo '<a href="' . admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug) . '&width=770&height=660&TB_iframe=true" class="thickbox" >';
158
+										echo '<span class="wpi-product-info">' . __('More info', 'invoicing') . '</span>';
159 159
 										echo '</a>';
160
-									}elseif(isset($addon->info->link) && ( substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com" || substr( $addon->info->link, 0, 21 ) === "https://wpgetpaid.com" ) ){
161
-										if(defined('WP_EASY_UPDATES_ACTIVE')){
162
-											$url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpgetpaid.com&TB_iframe=true');
163
-										}else{
160
+									}elseif (isset($addon->info->link) && (substr($addon->info->link, 0, 23) === "https://wpinvoicing.com" || substr($addon->info->link, 0, 21) === "https://wpgetpaid.com")) {
161
+										if (defined('WP_EASY_UPDATES_ACTIVE')) {
162
+											$url = admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpgetpaid.com&TB_iframe=true');
163
+										} else {
164 164
 											// if installed show activation link
165
-											if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){
165
+											if (isset($installed_plugins['wp-easy-updates/external-updates.php'])) {
166 166
 												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation';
167
-											}else{
167
+											} else {
168 168
 												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external';
169 169
 											}
170 170
 										}
171
-										echo '<a href="'.$url.'" class="thickbox">';
172
-										echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
171
+										echo '<a href="' . $url . '" class="thickbox">';
172
+										echo '<span class="wpi-product-info">' . __('More info', 'invoicing') . '</span>';
173 173
 										echo '</a>';
174 174
 									}
175 175
 
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 
181 181
 								<span class="wpi-product-button">
182 182
 									<?php
183
-                                    $addon_obj->output_button( $addon );
183
+                                    $addon_obj->output_button($addon);
184 184
 									?>
185 185
 								</span>
186 186
 
@@ -194,21 +194,21 @@  discard block
 block discarded – undo
194 194
 
195 195
 	<div class="clearfix" ></div>
196 196
 
197
-	<?php if($current_tab =='addons'){ ?>
198
-	<p><?php printf( __( 'All of our Invoicing Addons can be found on WPInvoicing.com here: <a href="%s">Invoicing Addons</a>', 'invoicing' ), 'https://wpinvoicing.com/downloads/category/addons/' ); ?></p>
199
-	<?php } if($current_tab =='gateways'){  ?>
200
-    <p><?php printf( __( 'All of our Invoicing Payment Gateways can be found on WPInvoicing.com here: <a href="%s">Invoicing Payment Gateways</a>', 'invoicing' ), 'https://wpinvoicing.com/downloads/category/gateways/' ); ?></p>
197
+	<?php if ($current_tab == 'addons') { ?>
198
+	<p><?php printf(__('All of our Invoicing Addons can be found on WPInvoicing.com here: <a href="%s">Invoicing Addons</a>', 'invoicing'), 'https://wpinvoicing.com/downloads/category/addons/'); ?></p>
199
+	<?php } if ($current_tab == 'gateways') {  ?>
200
+    <p><?php printf(__('All of our Invoicing Payment Gateways can be found on WPInvoicing.com here: <a href="%s">Invoicing Payment Gateways</a>', 'invoicing'), 'https://wpinvoicing.com/downloads/category/gateways/'); ?></p>
201 201
     <?php } ?>
202 202
 
203
-	<div id="wpi-wpeu-required-activation" style="display:none;"><span class="wpi-notification "><?php printf( __("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s'>activate</a> it now.",'invoicing'),wp_nonce_url(admin_url('plugins.php?action=activate&plugin=wp-easy-updates/external-updates.php'), 'activate-plugin_wp-easy-updates/external-updates.php'));?></span></div>
204
-	<div id="wpi-wpeu-required-for-external" style="display:none;"><span class="wpi-notification "><?php printf(  __("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s' onclick='window.open(\"https://wpeasyupdates.com/wp-easy-updates.zip\", \"_blank\");' >download</a> and install it now.",'invoicing'),admin_url("plugin-install.php?tab=upload&wpeu-install=true"));?></span></div>
203
+	<div id="wpi-wpeu-required-activation" style="display:none;"><span class="wpi-notification "><?php printf(__("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s'>activate</a> it now.", 'invoicing'), wp_nonce_url(admin_url('plugins.php?action=activate&plugin=wp-easy-updates/external-updates.php'), 'activate-plugin_wp-easy-updates/external-updates.php')); ?></span></div>
204
+	<div id="wpi-wpeu-required-for-external" style="display:none;"><span class="wpi-notification "><?php printf(__("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s' onclick='window.open(\"https://wpeasyupdates.com/wp-easy-updates.zip\", \"_blank\");' >download</a> and install it now.", 'invoicing'), admin_url("plugin-install.php?tab=upload&wpeu-install=true")); ?></span></div>
205 205
 	<div id="wpeu-licence-popup" style="display:none;">
206 206
 		<span class="wpi-notification noti-white">
207
-			<h3 class="wpeu-licence-title"><?php _e("Licence key",'invoicing');?></h3>
208
-			<input class="wpeu-licence-key" type="text" placeholder="<?php _e("Enter your licence key",'invoicing');?>"> <button class="button-primary wpeu-licence-popup-button" ><?php _e("Install",'invoicing');?></button>
207
+			<h3 class="wpeu-licence-title"><?php _e("Licence key", 'invoicing'); ?></h3>
208
+			<input class="wpeu-licence-key" type="text" placeholder="<?php _e("Enter your licence key", 'invoicing'); ?>"> <button class="button-primary wpeu-licence-popup-button" ><?php _e("Install", 'invoicing'); ?></button>
209 209
 			<br>
210 210
 			<?php
211
-			echo sprintf( __('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">','</a>','<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">','</a>' );
211
+			echo sprintf(__('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>');
212 212
 			?>
213 213
 		</span>
214 214
 	</div>
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 			</div>
127 127
 		</div>
128 128
 			<?php
129
-		}else{
129
+		} else{
130 130
 			$installed_plugins = get_plugins();
131 131
             $addon_obj = new WPInv_Admin_Addons();
132 132
 			if ($addons = $addon_obj->get_section_data( $current_tab ) ) :
@@ -157,14 +157,14 @@  discard block
 block discarded – undo
157 157
 										echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&width=770&height=660&TB_iframe=true" class="thickbox" >';
158 158
 										echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
159 159
 										echo '</a>';
160
-									}elseif(isset($addon->info->link) && ( substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com" || substr( $addon->info->link, 0, 21 ) === "https://wpgetpaid.com" ) ){
160
+									} elseif(isset($addon->info->link) && ( substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com" || substr( $addon->info->link, 0, 21 ) === "https://wpgetpaid.com" ) ){
161 161
 										if(defined('WP_EASY_UPDATES_ACTIVE')){
162 162
 											$url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpgetpaid.com&TB_iframe=true');
163
-										}else{
163
+										} else{
164 164
 											// if installed show activation link
165 165
 											if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){
166 166
 												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation';
167
-											}else{
167
+											} else{
168 168
 												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external';
169 169
 											}
170 170
 										}
Please login to merge, or discard this patch.
includes/wpinv-address-functions.php 2 patches
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -13,9 +13,9 @@  discard block
 block discarded – undo
13 13
 
14 14
 
15 15
 function wpinv_get_default_country() {
16
-	$country = wpinv_get_option( 'default_country', 'UK' );
16
+    $country = wpinv_get_option( 'default_country', 'UK' );
17 17
 
18
-	return apply_filters( 'wpinv_default_country', $country );
18
+    return apply_filters( 'wpinv_default_country', $country );
19 19
 }
20 20
 
21 21
 /**
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
  */
37 37
 function wpinv_sanitize_country( $country ) {
38 38
 
39
-	// Enure the country is specified
39
+    // Enure the country is specified
40 40
     if ( empty( $country ) ) {
41 41
         $country = wpinv_get_default_country();
42 42
     }
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 }
67 67
 
68 68
 function wpinv_get_default_state() {
69
-	$state = wpinv_get_option( 'default_state', '' );
69
+    $state = wpinv_get_option( 'default_state', '' );
70 70
 
71
-	return apply_filters( 'wpinv_default_state', $state );
71
+    return apply_filters( 'wpinv_default_state', $state );
72 72
 }
73 73
 
74 74
 function wpinv_state_name( $state_code = '', $country_code = '' ) {
@@ -305,11 +305,11 @@  discard block
 block discarded – undo
305 305
 
306 306
     $country = wpinv_sanitize_country( $country );
307 307
     
308
-	foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) {
309
-		if ( false !== array_search( $country, $countries, true ) ) {
310
-			return $continent_code;
311
-		}
312
-	}
308
+    foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) {
309
+        if ( false !== array_search( $country, $countries, true ) ) {
310
+            return $continent_code;
311
+        }
312
+    }
313 313
 
314 314
     return '';
315 315
     
@@ -601,33 +601,33 @@  discard block
 block discarded – undo
601 601
 }
602 602
 
603 603
 function wpinv_get_states_field() {
604
-	if( empty( $_POST['country'] ) ) {
605
-		$_POST['country'] = wpinv_get_default_country();
606
-	}
607
-	$states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) );
604
+    if( empty( $_POST['country'] ) ) {
605
+        $_POST['country'] = wpinv_get_default_country();
606
+    }
607
+    $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) );
608 608
 
609
-	if( !empty( $states ) ) {
610
-		$sanitized_field_name = sanitize_text_field( $_POST['field_name'] );
609
+    if( !empty( $states ) ) {
610
+        $sanitized_field_name = sanitize_text_field( $_POST['field_name'] );
611 611
 
612 612
         $class  = isset( $_POST['class'] ) ? esc_attr( $_POST['class'] ) : '';
613 613
         $class .= " $sanitized_field_name getpaid_js_field-state custom-select wpinv-select wpi_select2";
614 614
 
615 615
         $args  = array(
616
-			'name'    => $sanitized_field_name,
617
-			'id'      => $sanitized_field_name,
618
-			'class'   => implode( ' ', array_unique( explode( ' ', $class ) ) ),
619
-			'options' => array_merge( array( '' => '' ), $states ),
620
-			'show_option_all'  => false,
621
-			'show_option_none' => false
622
-		);
623
-
624
-		$response = wpinv_html_select( $args );
625
-
626
-	} else {
627
-		$response = 'nostates';
628
-	}
616
+            'name'    => $sanitized_field_name,
617
+            'id'      => $sanitized_field_name,
618
+            'class'   => implode( ' ', array_unique( explode( ' ', $class ) ) ),
619
+            'options' => array_merge( array( '' => '' ), $states ),
620
+            'show_option_all'  => false,
621
+            'show_option_none' => false
622
+        );
623
+
624
+        $response = wpinv_html_select( $args );
625
+
626
+    } else {
627
+        $response = 'nostates';
628
+    }
629 629
 
630
-	return $response;
630
+    return $response;
631 631
 }
632 632
 
633 633
 function wpinv_default_billing_country( $country = '', $user_id = 0 ) {
@@ -645,46 +645,46 @@  discard block
 block discarded – undo
645 645
  */
646 646
 function wpinv_get_address_formats() {
647 647
 
648
-		return apply_filters( 'wpinv_localisation_address_formats',
649
-			array(
650
-				'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}",
651
-				'AU'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}",
652
-				'AT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
653
-				'BE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
654
-				'CA'      => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{state_code}}&nbsp;&nbsp;{{zip}}\n{{country}}",
655
-				'CH'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
656
-				'CL'      => "{{company}}\n{{name}}\n{{address}}\n{{state}}\n{{zip}} {{city}}\n{{country}}",
657
-				'CN'      => "{{country}} {{zip}}\n{{state}}, {{city}}, {{address}}\n{{company}}\n{{name}}",
658
-				'CZ'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
659
-				'DE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
660
-				'EE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
661
-				'FI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
662
-				'DK'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
663
-				'FR'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city_upper}}\n{{country}}",
664
-				'HK'      => "{{company}}\n{{first_name}} {{last_name_upper}}\n{{address}}\n{{city_upper}}\n{{state_upper}}\n{{country}}",
665
-				'HU'      => "{{name}}\n{{company}}\n{{city}}\n{{address}}\n{{zip}}\n{{country}}",
666
-				'IN'      => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{zip}}\n{{state}}, {{country}}",
667
-				'IS'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
668
-				'IT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}}\n{{city}}\n{{state_upper}}\n{{country}}",
669
-				'JP'      => "{{zip}}\n{{state}} {{city}} {{address}}\n{{company}}\n{{last_name}} {{first_name}}\n{{country}}",
670
-				'TW'      => "{{company}}\n{{last_name}} {{first_name}}\n{{address}}\n{{state}}, {{city}} {{zip}}\n{{country}}",
671
-				'LI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
672
-				'NL'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
673
-				'NZ'      => "{{name}}\n{{company}}\n{{address}}\n{{city}} {{zip}}\n{{country}}",
674
-				'NO'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
675
-				'PL'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
676
-				'PT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
677
-				'SK'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
678
-				'RS'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
679
-				'SI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
680
-				'ES'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{state}}\n{{country}}",
681
-				'SE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
682
-				'TR'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}} {{state}}\n{{country}}",
683
-				'UG'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}, {{country}}",
684
-				'US'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}, {{state_code}} {{zip}}\n{{country}}",
685
-				'VN'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{country}}",
686
-			)
687
-		);
648
+        return apply_filters( 'wpinv_localisation_address_formats',
649
+            array(
650
+                'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}",
651
+                'AU'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}",
652
+                'AT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
653
+                'BE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
654
+                'CA'      => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{state_code}}&nbsp;&nbsp;{{zip}}\n{{country}}",
655
+                'CH'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
656
+                'CL'      => "{{company}}\n{{name}}\n{{address}}\n{{state}}\n{{zip}} {{city}}\n{{country}}",
657
+                'CN'      => "{{country}} {{zip}}\n{{state}}, {{city}}, {{address}}\n{{company}}\n{{name}}",
658
+                'CZ'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
659
+                'DE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
660
+                'EE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
661
+                'FI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
662
+                'DK'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
663
+                'FR'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city_upper}}\n{{country}}",
664
+                'HK'      => "{{company}}\n{{first_name}} {{last_name_upper}}\n{{address}}\n{{city_upper}}\n{{state_upper}}\n{{country}}",
665
+                'HU'      => "{{name}}\n{{company}}\n{{city}}\n{{address}}\n{{zip}}\n{{country}}",
666
+                'IN'      => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{zip}}\n{{state}}, {{country}}",
667
+                'IS'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
668
+                'IT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}}\n{{city}}\n{{state_upper}}\n{{country}}",
669
+                'JP'      => "{{zip}}\n{{state}} {{city}} {{address}}\n{{company}}\n{{last_name}} {{first_name}}\n{{country}}",
670
+                'TW'      => "{{company}}\n{{last_name}} {{first_name}}\n{{address}}\n{{state}}, {{city}} {{zip}}\n{{country}}",
671
+                'LI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
672
+                'NL'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
673
+                'NZ'      => "{{name}}\n{{company}}\n{{address}}\n{{city}} {{zip}}\n{{country}}",
674
+                'NO'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
675
+                'PL'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
676
+                'PT'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
677
+                'SK'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
678
+                'RS'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
679
+                'SI'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
680
+                'ES'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{state}}\n{{country}}",
681
+                'SE'      => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}",
682
+                'TR'      => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}} {{state}}\n{{country}}",
683
+                'UG'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}, {{country}}",
684
+                'US'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}, {{state_code}} {{zip}}\n{{country}}",
685
+                'VN'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{country}}",
686
+            )
687
+        );
688 688
 }
689 689
 
690 690
 /**
@@ -701,21 +701,21 @@  discard block
 block discarded – undo
701 701
     }
702 702
 
703 703
     // Get all formats.
704
-	$formats = wpinv_get_address_formats();
704
+    $formats = wpinv_get_address_formats();
705 705
 
706
-	// Get format for the specified country.
707
-	$format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default'];
706
+    // Get format for the specified country.
707
+    $format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default'];
708 708
     
709 709
     /**
710
-	 * Filters the address format to use on Invoices.
710
+     * Filters the address format to use on Invoices.
711 711
      * 
712 712
      * New lines will be replaced by a `br` element. Double new lines will be replaced by a paragraph. HTML tags are allowed.
713
-	 *
714
-	 * @since 1.0.13
715
-	 *
716
-	 * @param string $format  The address format to use.
713
+     *
714
+     * @since 1.0.13
715
+     *
716
+     * @param string $format  The address format to use.
717 717
      * @param string $country The country who's address format is being retrieved.
718
-	 */
718
+     */
719 719
     return apply_filters( 'wpinv_get_full_address_format', $format, $country );
720 720
 }
721 721
 
@@ -736,8 +736,8 @@  discard block
 block discarded – undo
736 736
         'country'           => '',
737 737
         'zip'               => '',
738 738
         'first_name'        => '',
739
-		'last_name'         => '',
740
-		'company'           => '',
739
+        'last_name'         => '',
740
+        'company'           => '',
741 741
     );
742 742
 
743 743
     $args    = map_deep( wp_parse_args( $billing_details, $default_args ), 'trim' );
@@ -758,14 +758,14 @@  discard block
 block discarded – undo
758 758
     $args['country_code']= $country;
759 759
 
760 760
     /**
761
-	 * Filters the address format replacements to use on Invoices.
761
+     * Filters the address format replacements to use on Invoices.
762 762
      * 
763
-	 *
764
-	 * @since 1.0.13
765
-	 *
766
-	 * @param array $replacements  The address replacements to use.
763
+     *
764
+     * @since 1.0.13
765
+     *
766
+     * @param array $replacements  The address replacements to use.
767 767
      * @param array $billing_details  The billing details to use.
768
-	 */
768
+     */
769 769
     $replacements = apply_filters( 'wpinv_get_invoice_address_replacements', $args, $billing_details );
770 770
 
771 771
     $return = array();
@@ -788,5 +788,5 @@  discard block
 block discarded – undo
788 788
  * @return string
789 789
  */
790 790
 function wpinv_trim_formatted_address_line( $line ) {
791
-	return trim( $line, ', ' );
791
+    return trim( $line, ', ' );
792 792
 }
793 793
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 
15 15
 function wpinv_get_default_country() {
16
-	$country = wpinv_get_option( 'default_country', 'UK' );
16
+	$country = wpinv_get_option('default_country', 'UK');
17 17
 
18
-	return apply_filters( 'wpinv_default_country', $country );
18
+	return apply_filters('wpinv_default_country', $country);
19 19
 }
20 20
 
21 21
 /**
@@ -23,8 +23,8 @@  discard block
 block discarded – undo
23 23
  *
24 24
  * @return string
25 25
  */
26
-function getpaid_get_ip_country( $ip_address = '' ) {
27
-    $country = GetPaid_Geolocation::geolocate_ip( $ip_address, true );
26
+function getpaid_get_ip_country($ip_address = '') {
27
+    $country = GetPaid_Geolocation::geolocate_ip($ip_address, true);
28 28
     return $country['country'];
29 29
 }
30 30
 
@@ -34,59 +34,59 @@  discard block
 block discarded – undo
34 34
  * @param string $country The country code to sanitize
35 35
  * @return array
36 36
  */
37
-function wpinv_sanitize_country( $country ) {
37
+function wpinv_sanitize_country($country) {
38 38
 
39 39
 	// Enure the country is specified
40
-    if ( empty( $country ) ) {
40
+    if (empty($country)) {
41 41
         $country = wpinv_get_default_country();
42 42
     }
43
-    return trim( wpinv_utf8_strtoupper( $country ) );
43
+    return trim(wpinv_utf8_strtoupper($country));
44 44
 
45 45
 }
46 46
 
47
-function wpinv_is_base_country( $country ) {
47
+function wpinv_is_base_country($country) {
48 48
     $base_country = wpinv_get_default_country();
49 49
     
50
-    if ( $base_country === 'UK' ) {
50
+    if ($base_country === 'UK') {
51 51
         $base_country = 'GB';
52 52
     }
53
-    if ( $country == 'UK' ) {
53
+    if ($country == 'UK') {
54 54
         $country = 'GB';
55 55
     }
56 56
 
57
-    return ( $country && $country === $base_country ) ? true : false;
57
+    return ($country && $country === $base_country) ? true : false;
58 58
 }
59 59
 
60
-function wpinv_country_name( $country_code = '' ) { 
60
+function wpinv_country_name($country_code = '') { 
61 61
     $countries = wpinv_get_country_list();
62 62
     $country_code = $country_code == 'UK' ? 'GB' : $country_code;
63
-    $country = isset( $countries[$country_code] ) ? $countries[$country_code] : $country_code;
63
+    $country = isset($countries[$country_code]) ? $countries[$country_code] : $country_code;
64 64
 
65
-    return apply_filters( 'wpinv_country_name', $country, $country_code );
65
+    return apply_filters('wpinv_country_name', $country, $country_code);
66 66
 }
67 67
 
68 68
 function wpinv_get_default_state() {
69
-	$state = wpinv_get_option( 'default_state', '' );
69
+	$state = wpinv_get_option('default_state', '');
70 70
 
71
-	return apply_filters( 'wpinv_default_state', $state );
71
+	return apply_filters('wpinv_default_state', $state);
72 72
 }
73 73
 
74
-function wpinv_state_name( $state_code = '', $country_code = '' ) {
74
+function wpinv_state_name($state_code = '', $country_code = '') {
75 75
     $state = $state_code;
76 76
     
77
-    if ( !empty( $country_code ) ) {
78
-        $states = wpinv_get_country_states( $country_code );
77
+    if (!empty($country_code)) {
78
+        $states = wpinv_get_country_states($country_code);
79 79
         
80
-        $state = !empty( $states ) && isset( $states[$state_code] ) ? $states[$state_code] : $state;
80
+        $state = !empty($states) && isset($states[$state_code]) ? $states[$state_code] : $state;
81 81
     }
82 82
 
83
-    return apply_filters( 'wpinv_state_name', $state, $state_code, $country_code );
83
+    return apply_filters('wpinv_state_name', $state, $state_code, $country_code);
84 84
 }
85 85
 
86 86
 function wpinv_store_address() {
87
-    $address = wpinv_get_option( 'store_address', '' );
87
+    $address = wpinv_get_option('store_address', '');
88 88
 
89
-    return apply_filters( 'wpinv_store_address', $address );
89
+    return apply_filters('wpinv_store_address', $address);
90 90
 }
91 91
 
92 92
 /**
@@ -94,24 +94,24 @@  discard block
 block discarded – undo
94 94
  *
95 95
  * @param WPInv_Invoice $invoice
96 96
  */
97
-function getpaid_maybe_add_default_address( &$invoice ) {
97
+function getpaid_maybe_add_default_address(&$invoice) {
98 98
 
99 99
     $user_id = $invoice->get_user_id();
100 100
 
101 101
     // Abort if the invoice belongs to no one.
102
-    if ( empty( $user_id ) ) {
102
+    if (empty($user_id)) {
103 103
         return;
104 104
     }
105 105
 
106 106
     // Fill in defaults whenever necessary.
107
-    foreach ( wpinv_get_user_address( $user_id ) as $key => $value ) {
107
+    foreach (wpinv_get_user_address($user_id) as $key => $value) {
108 108
 
109
-        if ( is_callable( $invoice, "get_$key" ) ) {
110
-            $current = call_user_func( array( $invoice, "get_$key" ) );
109
+        if (is_callable($invoice, "get_$key")) {
110
+            $current = call_user_func(array($invoice, "get_$key"));
111 111
 
112
-            if ( empty( $current ) ) {
112
+            if (empty($current)) {
113 113
                 $method = "set_$key";
114
-                $invoice->$method( $value );
114
+                $invoice->$method($value);
115 115
             }
116 116
 
117 117
         }
@@ -130,21 +130,21 @@  discard block
 block discarded – undo
130 130
     $address_fields = apply_filters(
131 131
         'getpaid_user_address_fields',
132 132
         array(
133
-            'first_name' => __( 'First Name', 'invoicing' ),
134
-            'last_name'  => __( 'Last Name', 'invoicing' ),
135
-            'address'    => __( 'Address', 'invoicing' ),
136
-            'city'       => __( 'City', 'invoicing' ),
137
-            'country'    => __( 'Country', 'invoicing' ),
138
-            'state'      => __( 'State', 'invoicing' ),
139
-            'zip'        => __( 'Zip/Postal Code', 'invoicing' ),
140
-            'phone'      => __( 'Phone Number', 'invoicing' ),
141
-            'company'    => __( 'Company', 'invoicing' ),
142
-            'vat_number' => __( 'VAT Number', 'invoicing' ),
133
+            'first_name' => __('First Name', 'invoicing'),
134
+            'last_name'  => __('Last Name', 'invoicing'),
135
+            'address'    => __('Address', 'invoicing'),
136
+            'city'       => __('City', 'invoicing'),
137
+            'country'    => __('Country', 'invoicing'),
138
+            'state'      => __('State', 'invoicing'),
139
+            'zip'        => __('Zip/Postal Code', 'invoicing'),
140
+            'phone'      => __('Phone Number', 'invoicing'),
141
+            'company'    => __('Company', 'invoicing'),
142
+            'vat_number' => __('VAT Number', 'invoicing'),
143 143
         )
144 144
     );
145 145
 
146
-    if ( ! wpinv_use_taxes() && isset( $address_fields['vat_number'] ) ) {
147
-        unset( $address_fields['vat_number'] );
146
+    if (!wpinv_use_taxes() && isset($address_fields['vat_number'])) {
147
+        unset($address_fields['vat_number']);
148 148
     }
149 149
 
150 150
     return $address_fields;
@@ -155,8 +155,8 @@  discard block
 block discarded – undo
155 155
  * 
156 156
  * @return bool
157 157
  */
158
-function getpaid_is_address_field_whitelisted( $key ) {
159
-    return array_key_exists( $key, getpaid_user_address_fields() );
158
+function getpaid_is_address_field_whitelisted($key) {
159
+    return array_key_exists($key, getpaid_user_address_fields());
160 160
 }
161 161
 
162 162
 /**
@@ -166,24 +166,24 @@  discard block
 block discarded – undo
166 166
  *
167 167
  * @param WPInv_Invoice $invoice
168 168
  */
169
-function getpaid_save_invoice_user_address( $invoice ) {
169
+function getpaid_save_invoice_user_address($invoice) {
170 170
 
171 171
     // Retrieve the invoice.
172
-    $invoice = wpinv_get_invoice( $invoice );
172
+    $invoice = wpinv_get_invoice($invoice);
173 173
 
174 174
     // Abort if it does not exist.
175
-    if ( empty( $invoice ) || $invoice->is_renewal() ) {
175
+    if (empty($invoice) || $invoice->is_renewal()) {
176 176
         return;
177 177
     }
178 178
 
179
-    foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
179
+    foreach (array_keys(getpaid_user_address_fields()) as $field) {
180 180
 
181
-        if ( is_callable( array( $invoice, "get_$field" ) ) ) {
182
-            $value = call_user_func( array( $invoice, "get_$field" ) );
181
+        if (is_callable(array($invoice, "get_$field"))) {
182
+            $value = call_user_func(array($invoice, "get_$field"));
183 183
 
184 184
             // Only save if it is not empty.
185
-            if ( ! empty( $value ) ) {
186
-                update_user_meta( $invoice->get_user_id(), '_wpinv_' . $field, $value );
185
+            if (!empty($value)) {
186
+                update_user_meta($invoice->get_user_id(), '_wpinv_' . $field, $value);
187 187
             }
188 188
 
189 189
         }
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
     }
192 192
 
193 193
 }
194
-add_action( 'getpaid_checkout_invoice_updated', 'getpaid_save_invoice_user_address' );
194
+add_action('getpaid_checkout_invoice_updated', 'getpaid_save_invoice_user_address');
195 195
 
196 196
 /**
197 197
  * Retrieves a saved user address.
@@ -200,14 +200,14 @@  discard block
 block discarded – undo
200 200
  * @param bool $with_default Whether or not we should use the default country and state.
201 201
  * @return array
202 202
  */
203
-function wpinv_get_user_address( $user_id = 0, $with_default = true ) {
203
+function wpinv_get_user_address($user_id = 0, $with_default = true) {
204 204
 
205 205
     // Prepare the user id.
206
-    $user_id   = empty( $user_id ) ? get_current_user_id() : $user_id;
207
-    $user_info = get_userdata( $user_id );
206
+    $user_id   = empty($user_id) ? get_current_user_id() : $user_id;
207
+    $user_info = get_userdata($user_id);
208 208
 
209 209
     // Abort if non exists.
210
-    if ( empty( $user_info ) ) {
210
+    if (empty($user_info)) {
211 211
         return array();
212 212
     }
213 213
 
@@ -217,11 +217,11 @@  discard block
 block discarded – undo
217 217
         'email'   => $user_info->user_email,
218 218
     );
219 219
 
220
-    foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
221
-        $address[$field] = getpaid_get_user_address_field( $user_id, $field );
220
+    foreach (array_keys(getpaid_user_address_fields()) as $field) {
221
+        $address[$field] = getpaid_get_user_address_field($user_id, $field);
222 222
     }
223 223
 
224
-    if ( ! $with_default ) {
224
+    if (!$with_default) {
225 225
         return $address;
226 226
     }
227 227
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
         'country'    => wpinv_get_default_country(),
233 233
     );
234 234
 
235
-    return getpaid_array_merge_if_empty( $address, $defaults );
235
+    return getpaid_array_merge_if_empty($address, $defaults);
236 236
 
237 237
 }
238 238
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
  * @param string $field The field to use.
244 244
  * @return string|null
245 245
  */
246
-function getpaid_get_user_address_field( $user_id, $field ) {
246
+function getpaid_get_user_address_field($user_id, $field) {
247 247
 
248 248
     $prefixes = array(
249 249
         '_wpinv_',
@@ -251,15 +251,15 @@  discard block
 block discarded – undo
251 251
         ''
252 252
     );
253 253
 
254
-    foreach ( $prefixes as $prefix ) {
254
+    foreach ($prefixes as $prefix) {
255 255
 
256 256
         // Meta table.
257
-        $value = get_user_meta( $user_id, $prefix . $field, true );
257
+        $value = get_user_meta($user_id, $prefix . $field, true);
258 258
         
259 259
         // UWP table.
260
-        $value = ( empty( $value ) && function_exists( 'uwp_get_usermeta' ) ) ? uwp_get_usermeta( $user_id, $prefix . $field ) : $value;
260
+        $value = (empty($value) && function_exists('uwp_get_usermeta')) ? uwp_get_usermeta($user_id, $prefix . $field) : $value;
261 261
 
262
-        if ( ! empty( $value ) ) {
262
+        if (!empty($value)) {
263 263
             return $value;
264 264
         }
265 265
 
@@ -276,16 +276,16 @@  discard block
 block discarded – undo
276 276
  * @param string $return What to return.
277 277
  * @return array
278 278
  */
279
-function wpinv_get_continents( $return = 'all' ) {
279
+function wpinv_get_continents($return = 'all') {
280 280
 
281
-    $continents = wpinv_get_data( 'continents' );
281
+    $continents = wpinv_get_data('continents');
282 282
 
283
-    switch( $return ) {
283
+    switch ($return) {
284 284
         case 'name' :
285
-            return wp_list_pluck( $continents, 'name' );
285
+            return wp_list_pluck($continents, 'name');
286 286
             break;
287 287
         case 'countries' :
288
-            return wp_list_pluck( $continents, 'countries' );
288
+            return wp_list_pluck($continents, 'countries');
289 289
             break;
290 290
         default :
291 291
             return $continents;
@@ -301,12 +301,12 @@  discard block
 block discarded – undo
301 301
  * @param string $country Country code. If no code is specified, defaults to the default country.
302 302
  * @return string
303 303
  */
304
-function wpinv_get_continent_code_for_country( $country = false ) {
304
+function wpinv_get_continent_code_for_country($country = false) {
305 305
 
306
-    $country = wpinv_sanitize_country( $country );
306
+    $country = wpinv_sanitize_country($country);
307 307
     
308
-	foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) {
309
-		if ( false !== array_search( $country, $countries, true ) ) {
308
+	foreach (wpinv_get_continents('countries') as $continent_code => $countries) {
309
+		if (false !== array_search($country, $countries, true)) {
310 310
 			return $continent_code;
311 311
 		}
312 312
 	}
@@ -322,13 +322,13 @@  discard block
 block discarded – undo
322 322
  * @param string $country Country code. If no code is specified, defaults to the default country.
323 323
  * @return array
324 324
  */
325
-function wpinv_get_country_calling_code( $country = null) {
325
+function wpinv_get_country_calling_code($country = null) {
326 326
 
327
-    $country = wpinv_sanitize_country( $country );
328
-    $codes   = wpinv_get_data( 'phone-codes' );
329
-    $code    = isset( $codes[ $country ] ) ? $codes[ $country ] : '';
327
+    $country = wpinv_sanitize_country($country);
328
+    $codes   = wpinv_get_data('phone-codes');
329
+    $code    = isset($codes[$country]) ? $codes[$country] : '';
330 330
 
331
-    if ( is_array( $code ) ) {
331
+    if (is_array($code)) {
332 332
         return $code[0];
333 333
     }
334 334
     return $code;
@@ -341,8 +341,8 @@  discard block
 block discarded – undo
341 341
  * @param bool $first_empty Whether or not the first item in the list should be empty
342 342
  * @return array
343 343
  */
344
-function wpinv_get_country_list( $first_empty = false ) {
345
-    return wpinv_maybe_add_empty_option( apply_filters( 'wpinv_countries', wpinv_get_data( 'countries' ) ), $first_empty );
344
+function wpinv_get_country_list($first_empty = false) {
345
+    return wpinv_maybe_add_empty_option(apply_filters('wpinv_countries', wpinv_get_data('countries')), $first_empty);
346 346
 }
347 347
 
348 348
 /**
@@ -352,22 +352,22 @@  discard block
 block discarded – undo
352 352
  * @param bool $first_empty Whether or not the first item in the list should be empty
353 353
  * @return array
354 354
  */
355
-function wpinv_get_country_states( $country = null, $first_empty = false ) {
355
+function wpinv_get_country_states($country = null, $first_empty = false) {
356 356
     
357 357
     // Prepare the country.
358
-    $country = wpinv_sanitize_country( $country );
358
+    $country = wpinv_sanitize_country($country);
359 359
 
360 360
     // Fetch all states.
361
-    $all_states = wpinv_get_data( 'states' );
361
+    $all_states = wpinv_get_data('states');
362 362
 
363 363
     // Fetch the specified country's states.
364
-    $states     = isset( $all_states[ $country ] ) ? $all_states[ $country ] : array() ;
365
-    $states     = apply_filters( "wpinv_{$country}_states", $states );
366
-    $states     = apply_filters( 'wpinv_country_states', $states, $country );
364
+    $states     = isset($all_states[$country]) ? $all_states[$country] : array();
365
+    $states     = apply_filters("wpinv_{$country}_states", $states);
366
+    $states     = apply_filters('wpinv_country_states', $states, $country);
367 367
 
368
-    asort( $states );
368
+    asort($states);
369 369
      
370
-    return wpinv_maybe_add_empty_option( $states, $first_empty );
370
+    return wpinv_maybe_add_empty_option($states, $first_empty);
371 371
 }
372 372
 
373 373
 /**
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
  * @return array
378 378
  */
379 379
 function wpinv_get_us_states_list() {
380
-    return apply_filters( 'wpinv_usa_states', wpinv_get_country_states( 'US' ) );
380
+    return apply_filters('wpinv_usa_states', wpinv_get_country_states('US'));
381 381
 }
382 382
 
383 383
 /**
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
  * @return array
388 388
  */
389 389
 function wpinv_get_canada_states_list() {
390
-    return apply_filters( 'wpinv_canada_provinces', wpinv_get_country_states( 'CA' ) );
390
+    return apply_filters('wpinv_canada_provinces', wpinv_get_country_states('CA'));
391 391
 }
392 392
 
393 393
 /**
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
  * @return array
398 398
  */
399 399
 function wpinv_get_australia_states_list() {
400
-    return apply_filters( 'wpinv_australia_states', wpinv_get_country_states( 'AU' ) );
400
+    return apply_filters('wpinv_australia_states', wpinv_get_country_states('AU'));
401 401
 }
402 402
 
403 403
 /**
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
  * @return array
408 408
  */
409 409
 function wpinv_get_bangladesh_states_list() {
410
-    return apply_filters( 'wpinv_bangladesh_states', wpinv_get_country_states( 'BD' ) );
410
+    return apply_filters('wpinv_bangladesh_states', wpinv_get_country_states('BD'));
411 411
 }
412 412
 
413 413
 /**
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
  * @return array
418 418
  */
419 419
 function wpinv_get_brazil_states_list() {
420
-    return apply_filters( 'wpinv_brazil_states', wpinv_get_country_states( 'BR' ) );
420
+    return apply_filters('wpinv_brazil_states', wpinv_get_country_states('BR'));
421 421
 }
422 422
 
423 423
 /**
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
  * @return array
428 428
  */
429 429
 function wpinv_get_bulgaria_states_list() {
430
-    return apply_filters( 'wpinv_bulgaria_states', wpinv_get_country_states( 'BG' ) );
430
+    return apply_filters('wpinv_bulgaria_states', wpinv_get_country_states('BG'));
431 431
 }
432 432
 
433 433
 /**
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
  * @return array
438 438
  */
439 439
 function wpinv_get_hong_kong_states_list() {
440
-    return apply_filters( 'wpinv_hong_kong_states', wpinv_get_country_states( 'HK' ) );
440
+    return apply_filters('wpinv_hong_kong_states', wpinv_get_country_states('HK'));
441 441
 }
442 442
 
443 443
 /**
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
  * @return array
448 448
  */
449 449
 function wpinv_get_hungary_states_list() {
450
-    return apply_filters( 'wpinv_hungary_states', wpinv_get_country_states( 'HU' ) );
450
+    return apply_filters('wpinv_hungary_states', wpinv_get_country_states('HU'));
451 451
 }
452 452
 
453 453
 /**
@@ -457,7 +457,7 @@  discard block
 block discarded – undo
457 457
  * @return array
458 458
  */
459 459
 function wpinv_get_japan_states_list() {
460
-    return apply_filters( 'wpinv_japan_states', wpinv_get_country_states( 'JP' ) );
460
+    return apply_filters('wpinv_japan_states', wpinv_get_country_states('JP'));
461 461
 }
462 462
 
463 463
 /**
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
  * @return array
468 468
  */
469 469
 function wpinv_get_china_states_list() {
470
-    return apply_filters( 'wpinv_china_states', wpinv_get_country_states( 'CN' ) );
470
+    return apply_filters('wpinv_china_states', wpinv_get_country_states('CN'));
471 471
 }
472 472
 
473 473
 /**
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
  * @return array
478 478
  */
479 479
 function wpinv_get_new_zealand_states_list() {
480
-    return apply_filters( 'wpinv_new_zealand_states', wpinv_get_country_states( 'NZ' ) );
480
+    return apply_filters('wpinv_new_zealand_states', wpinv_get_country_states('NZ'));
481 481
 }
482 482
 
483 483
 /**
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
  * @return array
488 488
  */
489 489
 function wpinv_get_peru_states_list() {
490
-    return apply_filters( 'wpinv_peru_states', wpinv_get_country_states( 'PE' ) );
490
+    return apply_filters('wpinv_peru_states', wpinv_get_country_states('PE'));
491 491
 }
492 492
 
493 493
 /**
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
  * @return array
498 498
  */
499 499
 function wpinv_get_indonesia_states_list() {
500
-    return apply_filters( 'wpinv_indonesia_states', wpinv_get_country_states( 'ID' ) );
500
+    return apply_filters('wpinv_indonesia_states', wpinv_get_country_states('ID'));
501 501
 }
502 502
 
503 503
 /**
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
  * @return array
508 508
  */
509 509
 function wpinv_get_india_states_list() {
510
-    return apply_filters( 'wpinv_india_states', wpinv_get_country_states( 'IN' ) );
510
+    return apply_filters('wpinv_india_states', wpinv_get_country_states('IN'));
511 511
 }
512 512
 
513 513
 /**
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
  * @return array
518 518
  */
519 519
 function wpinv_get_iran_states_list() {
520
-    return apply_filters( 'wpinv_iran_states', wpinv_get_country_states( 'IR' ) );
520
+    return apply_filters('wpinv_iran_states', wpinv_get_country_states('IR'));
521 521
 }
522 522
 
523 523
 /**
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
  * @return array
528 528
  */
529 529
 function wpinv_get_italy_states_list() {
530
-    return apply_filters( 'wpinv_italy_states', wpinv_get_country_states( 'IT' ) );
530
+    return apply_filters('wpinv_italy_states', wpinv_get_country_states('IT'));
531 531
 }
532 532
 
533 533
 /**
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
  * @return array
538 538
  */
539 539
 function wpinv_get_malaysia_states_list() {
540
-    return apply_filters( 'wpinv_malaysia_states', wpinv_get_country_states( 'MY' ) );
540
+    return apply_filters('wpinv_malaysia_states', wpinv_get_country_states('MY'));
541 541
 }
542 542
 
543 543
 /**
@@ -547,7 +547,7 @@  discard block
 block discarded – undo
547 547
  * @return array
548 548
  */
549 549
 function wpinv_get_mexico_states_list() {
550
-    return apply_filters( 'wpinv_mexico_states', wpinv_get_country_states( 'MX' ) );
550
+    return apply_filters('wpinv_mexico_states', wpinv_get_country_states('MX'));
551 551
 }
552 552
 
553 553
 /**
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
  * @return array
558 558
  */
559 559
 function wpinv_get_nepal_states_list() {
560
-    return apply_filters( 'wpinv_nepal_states', wpinv_get_country_states( 'NP' ) );
560
+    return apply_filters('wpinv_nepal_states', wpinv_get_country_states('NP'));
561 561
 }
562 562
 
563 563
 /**
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
  * @return array
568 568
  */
569 569
 function wpinv_get_south_africa_states_list() {
570
-    return apply_filters( 'wpinv_south_africa_states', wpinv_get_country_states( 'ZA' ) );
570
+    return apply_filters('wpinv_south_africa_states', wpinv_get_country_states('ZA'));
571 571
 }
572 572
 
573 573
 /**
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
  * @return array
578 578
  */
579 579
 function wpinv_get_thailand_states_list() {
580
-    return apply_filters( 'wpinv_thailand_states', wpinv_get_country_states( 'TH' ) );
580
+    return apply_filters('wpinv_thailand_states', wpinv_get_country_states('TH'));
581 581
 }
582 582
 
583 583
 /**
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
  * @return array
588 588
  */
589 589
 function wpinv_get_turkey_states_list() {
590
-    return apply_filters( 'wpinv_turkey_states', wpinv_get_country_states( 'TR' ) );
590
+    return apply_filters('wpinv_turkey_states', wpinv_get_country_states('TR'));
591 591
 }
592 592
 
593 593
 /**
@@ -597,31 +597,31 @@  discard block
 block discarded – undo
597 597
  * @return array
598 598
  */
599 599
 function wpinv_get_spain_states_list() {
600
-    return apply_filters( 'wpinv_spain_states', wpinv_get_country_states( 'ES' ) );
600
+    return apply_filters('wpinv_spain_states', wpinv_get_country_states('ES'));
601 601
 }
602 602
 
603 603
 function wpinv_get_states_field() {
604
-	if( empty( $_POST['country'] ) ) {
604
+	if (empty($_POST['country'])) {
605 605
 		$_POST['country'] = wpinv_get_default_country();
606 606
 	}
607
-	$states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) );
607
+	$states = wpinv_get_country_states(sanitize_text_field($_POST['country']));
608 608
 
609
-	if( !empty( $states ) ) {
610
-		$sanitized_field_name = sanitize_text_field( $_POST['field_name'] );
609
+	if (!empty($states)) {
610
+		$sanitized_field_name = sanitize_text_field($_POST['field_name']);
611 611
 
612
-        $class  = isset( $_POST['class'] ) ? esc_attr( $_POST['class'] ) : '';
612
+        $class  = isset($_POST['class']) ? esc_attr($_POST['class']) : '';
613 613
         $class .= " $sanitized_field_name getpaid_js_field-state custom-select wpinv-select wpi_select2";
614 614
 
615
-        $args  = array(
615
+        $args = array(
616 616
 			'name'    => $sanitized_field_name,
617 617
 			'id'      => $sanitized_field_name,
618
-			'class'   => implode( ' ', array_unique( explode( ' ', $class ) ) ),
619
-			'options' => array_merge( array( '' => '' ), $states ),
618
+			'class'   => implode(' ', array_unique(explode(' ', $class))),
619
+			'options' => array_merge(array('' => ''), $states),
620 620
 			'show_option_all'  => false,
621 621
 			'show_option_none' => false
622 622
 		);
623 623
 
624
-		$response = wpinv_html_select( $args );
624
+		$response = wpinv_html_select($args);
625 625
 
626 626
 	} else {
627 627
 		$response = 'nostates';
@@ -630,10 +630,10 @@  discard block
 block discarded – undo
630 630
 	return $response;
631 631
 }
632 632
 
633
-function wpinv_default_billing_country( $country = '', $user_id = 0 ) {
634
-    $country = !empty( $country ) ? $country : wpinv_get_default_country();
633
+function wpinv_default_billing_country($country = '', $user_id = 0) {
634
+    $country = !empty($country) ? $country : wpinv_get_default_country();
635 635
     
636
-    return apply_filters( 'wpinv_default_billing_country', $country, $user_id );
636
+    return apply_filters('wpinv_default_billing_country', $country, $user_id);
637 637
 }
638 638
 
639 639
 /**
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
  */
646 646
 function wpinv_get_address_formats() {
647 647
 
648
-		return apply_filters( 'wpinv_localisation_address_formats',
648
+		return apply_filters('wpinv_localisation_address_formats',
649 649
 			array(
650 650
 				'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}",
651 651
 				'AU'      => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}",
@@ -694,9 +694,9 @@  discard block
 block discarded – undo
694 694
  * @see `wpinv_get_invoice_address_replacements`
695 695
  * @return string
696 696
  */
697
-function wpinv_get_full_address_format( $country = false) {
697
+function wpinv_get_full_address_format($country = false) {
698 698
 
699
-    if( empty( $country ) ) {
699
+    if (empty($country)) {
700 700
         $country = wpinv_get_default_country();
701 701
     }
702 702
 
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 	$formats = wpinv_get_address_formats();
705 705
 
706 706
 	// Get format for the specified country.
707
-	$format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default'];
707
+	$format = ($country && isset($formats[$country])) ? $formats[$country] : $formats['default'];
708 708
     
709 709
     /**
710 710
 	 * Filters the address format to use on Invoices.
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
 	 * @param string $format  The address format to use.
717 717
      * @param string $country The country who's address format is being retrieved.
718 718
 	 */
719
-    return apply_filters( 'wpinv_get_full_address_format', $format, $country );
719
+    return apply_filters('wpinv_get_full_address_format', $format, $country);
720 720
 }
721 721
 
722 722
 /**
@@ -727,7 +727,7 @@  discard block
 block discarded – undo
727 727
  * @param array $billing_details customer's billing details
728 728
  * @return array
729 729
  */
730
-function wpinv_get_invoice_address_replacements( $billing_details ) {
730
+function wpinv_get_invoice_address_replacements($billing_details) {
731 731
 
732 732
     $default_args = array(
733 733
         'address'           => '',
@@ -740,22 +740,22 @@  discard block
 block discarded – undo
740 740
 		'company'           => '',
741 741
     );
742 742
 
743
-    $args    = map_deep( wp_parse_args( $billing_details, $default_args ), 'trim' );
743
+    $args    = map_deep(wp_parse_args($billing_details, $default_args), 'trim');
744 744
     $state   = $args['state'];
745 745
     $country = $args['country'];
746 746
 
747 747
     // Handle full country name.
748
-    $full_country = empty( $country ) ? $country : wpinv_country_name( $country );
748
+    $full_country = empty($country) ? $country : wpinv_country_name($country);
749 749
 
750 750
     // Handle full state name.
751
-    $full_state   = ( $country && $state ) ?  wpinv_state_name( $state, $country ) : $state;
751
+    $full_state   = ($country && $state) ?  wpinv_state_name($state, $country) : $state;
752 752
 
753 753
     $args['postcode']    = $args['zip'];
754 754
     $args['name']        = $args['first_name'] . ' ' . $args['last_name'];
755 755
     $args['state']       = $full_state;
756 756
     $args['state_code']  = $state;
757 757
     $args['country']     = $full_country;
758
-    $args['country_code']= $country;
758
+    $args['country_code'] = $country;
759 759
 
760 760
     /**
761 761
 	 * Filters the address format replacements to use on Invoices.
@@ -766,14 +766,14 @@  discard block
 block discarded – undo
766 766
 	 * @param array $replacements  The address replacements to use.
767 767
      * @param array $billing_details  The billing details to use.
768 768
 	 */
769
-    $replacements = apply_filters( 'wpinv_get_invoice_address_replacements', $args, $billing_details );
769
+    $replacements = apply_filters('wpinv_get_invoice_address_replacements', $args, $billing_details);
770 770
 
771 771
     $return = array();
772 772
 
773
-    foreach( $replacements as $key => $value ) {
774
-        $value  = is_scalar( $value ) ? trim( sanitize_text_field( $value ) ) : '';
773
+    foreach ($replacements as $key => $value) {
774
+        $value = is_scalar($value) ? trim(sanitize_text_field($value)) : '';
775 775
         $return['{{' . $key . '}}'] = $value;
776
-        $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper( $value );
776
+        $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper($value);
777 777
     }
778 778
 
779 779
     return $return;
@@ -787,6 +787,6 @@  discard block
 block discarded – undo
787 787
  * @since 1.0.14
788 788
  * @return string
789 789
  */
790
-function wpinv_trim_formatted_address_line( $line ) {
791
-	return trim( $line, ', ' );
790
+function wpinv_trim_formatted_address_line($line) {
791
+	return trim($line, ', ');
792 792
 }
793 793
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/views/wizard-header.php 3 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@
 block discarded – undo
20 20
 			<title><?php esc_html_e( 'GetPaid &rsaquo; Setup Wizard', 'invoicing' ); ?></title>
21 21
 			<?php
22 22
                 getpaid_admin()->enqeue_scripts();
23
-				wp_enqueue_style( 'font-awesome', 'https://use.fontawesome.com/releases/v5.13.0/css/all.css', array(), 'v5.13.0' );
24
-				wp_print_styles( 'select2' );
23
+                wp_enqueue_style( 'font-awesome', 'https://use.fontawesome.com/releases/v5.13.0/css/all.css', array(), 'v5.13.0' );
24
+                wp_print_styles( 'select2' );
25 25
                 wp_print_scripts( 'select2' );
26
-				wp_print_scripts( 'wpinv-admin-script' );
26
+                wp_print_scripts( 'wpinv-admin-script' );
27 27
                 do_action( 'admin_print_styles' );
28 28
                 do_action( 'admin_head' );
29
-			?>
29
+            ?>
30 30
 			<style>
31 31
 				body, p{
32 32
 					font-size: 16px;
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 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
 $aui_settings = AyeCode_UI_Settings::instance();
10 10
 $aui_settings->enqueue_scripts();
@@ -17,15 +17,15 @@  discard block
 block discarded – undo
17 17
 		<head>
18 18
 			<meta name="viewport" content="width=device-width"/>
19 19
 			<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
20
-			<title><?php esc_html_e( 'GetPaid &rsaquo; Setup Wizard', 'invoicing' ); ?></title>
20
+			<title><?php esc_html_e('GetPaid &rsaquo; Setup Wizard', 'invoicing'); ?></title>
21 21
 			<?php
22 22
                 getpaid_admin()->enqeue_scripts();
23
-				wp_enqueue_style( 'font-awesome', 'https://use.fontawesome.com/releases/v5.13.0/css/all.css', array(), 'v5.13.0' );
24
-				wp_print_styles( 'select2' );
25
-                wp_print_scripts( 'select2' );
26
-				wp_print_scripts( 'wpinv-admin-script' );
27
-                do_action( 'admin_print_styles' );
28
-                do_action( 'admin_head' );
23
+				wp_enqueue_style('font-awesome', 'https://use.fontawesome.com/releases/v5.13.0/css/all.css', array(), 'v5.13.0');
24
+				wp_print_styles('select2');
25
+                wp_print_scripts('select2');
26
+				wp_print_scripts('wpinv-admin-script');
27
+                do_action('admin_print_styles');
28
+                do_action('admin_head');
29 29
 			?>
30 30
 			<style>
31 31
 				body, p{
@@ -37,21 +37,21 @@  discard block
 block discarded – undo
37 37
                     font-weight: 500;
38 38
                     margin-bottom: .1rem;
39 39
                 }
40
-				<?php echo $aui_settings::css_primary( '#009874', true ); ?>
40
+				<?php echo $aui_settings::css_primary('#009874', true); ?>
41 41
 			</style>
42 42
 		</head>
43 43
 
44 44
         <body class="gp-setup wp-core-ui bg-lightx mx-auto text-dark scrollbars-ios" style="background: #f3f6ff;">
45 45
 
46
-            <?php if ( isset( $_REQUEST['step'] ) ) : ?>
46
+            <?php if (isset($_REQUEST['step'])) : ?>
47 47
                 <ol class="gp-setup-steps mb-0 pb-4 mw-100 list-group list-group-horizontal text-center">
48
-                    <?php foreach ( $steps as $step => $data ) : ?>
48
+                    <?php foreach ($steps as $step => $data) : ?>
49 49
                         <li class="list-group-item flex-fill rounded-0 <?php
50 50
                             echo $step == $current ? 'active' : 'd-none d-md-block';
51
-                            echo array_search( $current, array_keys( $steps ) ) > array_search( $step, array_keys( $steps ) ) ? ' done' : '';
51
+                            echo array_search($current, array_keys($steps)) > array_search($step, array_keys($steps)) ? ' done' : '';
52 52
                         ?>">
53
-                            <i class="far fa-check-circle <?php echo array_search( $current, array_keys( $steps ) ) > array_search( $step, array_keys( $steps ) ) ? 'text-success' : '' ;?>"></i>
54
-                            <?php echo esc_html( $data['name'] ); ?>
53
+                            <i class="far fa-check-circle <?php echo array_search($current, array_keys($steps)) > array_search($step, array_keys($steps)) ? 'text-success' : ''; ?>"></i>
54
+                            <?php echo esc_html($data['name']); ?>
55 55
                         </li>
56 56
                     <?php endforeach; ?>
57 57
                 </ol>
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
             <div class="text-center pb-3 mt-5">
63 63
                 <a class=" text-decoration-none" href="https://wpgetpaid.com/">
64 64
                     <span class="text-black-50">
65
-                        <img class="ml-n3x" src="<?php echo WPINV_PLUGIN_URL . 'assets/images/getpaid-logo.png';?>" />
65
+                        <img class="ml-n3x" src="<?php echo WPINV_PLUGIN_URL . 'assets/images/getpaid-logo.png'; ?>" />
66 66
                     </span>
67 67
                 </a>
68 68
             </div>
69 69
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -55,9 +55,12 @@
 block discarded – undo
55 55
                         </li>
56 56
                     <?php endforeach; ?>
57 57
                 </ol>
58
-            <?php else: ?>
58
+            <?php else {
59
+    : ?>
59 60
                 <div class='mb-3'>&nbsp;</div>
60
-            <?php endif; ?>
61
+            <?php endif;
62
+}
63
+?>
61 64
 
62 65
             <div class="text-center pb-3 mt-5">
63 66
                 <a class=" text-decoration-none" href="https://wpgetpaid.com/">
Please login to merge, or discard this patch.
includes/admin/views/wizard-plugins.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -4,30 +4,30 @@  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
 
11 11
 <div class="card shadow-sm my-5">'
12 12
 
13
-    <form method="post" class="text-center card-body" action="<?php echo esc_url( admin_url() ); ?>">
14
-		<?php getpaid_hidden_field( 'getpaid-admin-action', 'install_plugin' ); ?>
15
-		<?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?>
16
-		<?php getpaid_hidden_field( 'redirect', $next_url ); ?>
13
+    <form method="post" class="text-center card-body" action="<?php echo esc_url(admin_url()); ?>">
14
+		<?php getpaid_hidden_field('getpaid-admin-action', 'install_plugin'); ?>
15
+		<?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?>
16
+		<?php getpaid_hidden_field('redirect', $next_url); ?>
17 17
 		<div class="gd-wizard-recommend">
18 18
 
19
-			<h2 class="gd-settings-title h3"><?php _e( 'Recommended Plugins', 'invoicing' ); ?></h2>
20
-			<p><?php _e( 'Below are a few of our own plugins that may help you.', 'invoicing' ); ?></p>
19
+			<h2 class="gd-settings-title h3"><?php _e('Recommended Plugins', 'invoicing'); ?></h2>
20
+			<p><?php _e('Below are a few of our own plugins that may help you.', 'invoicing'); ?></p>
21 21
 
22 22
 			<ul class="list-group">
23
-				<?php foreach ( $recommended_plugins as $plugin ) : ?>
23
+				<?php foreach ($recommended_plugins as $plugin) : ?>
24 24
 				<li class="list-group-item d-flex justify-content-between align-items-center flex-wrap text-left">
25
-					<span class="mr-auto"><?php echo esc_html( $plugin['name'] ); ?></span>
25
+					<span class="mr-auto"><?php echo esc_html($plugin['name']); ?></span>
26 26
 					<div class="custom-control custom-switch getpaid-install-plugin-siwtch-div mr-n2">
27
-						<input type="checkbox" name="plugins[<?php echo esc_attr( $plugin['slug'] ); ?>]" value="<?php echo esc_attr( $plugin['file'] ); ?>" class="custom-control-input"  <?php if( is_plugin_active( $plugin['slug'] ) ){echo "checked";} ?>>
27
+						<input type="checkbox" name="plugins[<?php echo esc_attr($plugin['slug']); ?>]" value="<?php echo esc_attr($plugin['file']); ?>" class="custom-control-input"  <?php if (is_plugin_active($plugin['slug'])) {echo "checked"; } ?>>
28 28
 						<label class="custom-control-label" for="ac-setting-updates"></label>
29 29
 					</div>
30
-					<small class="w-100"><?php echo esc_attr( $plugin['desc'] );?></small>
30
+					<small class="w-100"><?php echo esc_attr($plugin['desc']); ?></small>
31 31
 				</li>
32 32
 				<?php endforeach; ?>
33 33
 			</ul>
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 				<input
37 37
                 	type="submit"
38 38
                 	class="btn btn-primary button-next"
39
-				    value="<?php esc_attr_e( 'Continue', 'invoicing' ); ?>" name="save_step"/>
39
+				    value="<?php esc_attr_e('Continue', 'invoicing'); ?>" name="save_step"/>
40 40
 			</p>
41 41
 
42 42
 		</div>
Please login to merge, or discard this patch.
includes/admin/views/wizard-settings.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -4,15 +4,15 @@  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
 
11 11
 <div class="card shadow-sm my-5">
12 12
 
13 13
     <form method="post" class="text-left card-body" action="options.php">
14
-        <?php settings_fields( 'wpinv_settings' ); ?>
15
-        <input type="hidden" name="_wp_http_referer" value="<?php echo esc_url( $next_url ); ?>">
14
+        <?php settings_fields('wpinv_settings'); ?>
15
+        <input type="hidden" name="_wp_http_referer" value="<?php echo esc_url($next_url); ?>">
16 16
 
17 17
         <table class="gp-setup-maps w-100 " cellspacing="0">
18 18
             <tbody>
@@ -20,28 +20,28 @@  discard block
 block discarded – undo
20 20
 
21 21
                     global $wp_settings_fields;
22 22
 
23
-                    if ( isset( $wp_settings_fields[ $page ][ $section ] ) ) {
24
-                        $settings =  $wp_settings_fields[ $page ][ $section ];
23
+                    if (isset($wp_settings_fields[$page][$section])) {
24
+                        $settings = $wp_settings_fields[$page][$section];
25 25
 
26
-                        foreach ( $settings as $field ) {
26
+                        foreach ($settings as $field) {
27 27
 
28
-                            $name      = esc_attr( $field['id'] );
29
-                            $id        = sanitize_key( $name );
28
+                            $name      = esc_attr($field['id']);
29
+                            $id        = sanitize_key($name);
30 30
                             $class     = '';
31
-                            $value     = isset( $field['args']['std'] ) ? $field['args']['std'] : '';
32
-                            $value     = wpinv_clean( wpinv_get_option( $field['args']['id'], $value ) );
33
-                            $help_text = isset( $field['args']['desc'] ) ? wp_kses_post( $field['args']['desc'] ) : '';
34
-                            $type      = str_replace( 'wpinv_', '', str_replace( '_callback', '', $field['callback'] ) );
35
-                            $label     = isset( $field['args']['name'] ) ? wp_kses_post( $field['args']['name'] ) : '';
36
-                            $options   = isset( $field['args']['options'] ) ? $field['args']['options'] : array();
31
+                            $value     = isset($field['args']['std']) ? $field['args']['std'] : '';
32
+                            $value     = wpinv_clean(wpinv_get_option($field['args']['id'], $value));
33
+                            $help_text = isset($field['args']['desc']) ? wp_kses_post($field['args']['desc']) : '';
34
+                            $type      = str_replace('wpinv_', '', str_replace('_callback', '', $field['callback']));
35
+                            $label     = isset($field['args']['name']) ? wp_kses_post($field['args']['name']) : '';
36
+                            $options   = isset($field['args']['options']) ? $field['args']['options'] : array();
37 37
                         
38
-                            if ( false !== strpos( $name, 'logo') ) {
38
+                            if (false !== strpos($name, 'logo')) {
39 39
                                 $type = 'hidden';
40 40
                             }
41 41
                         
42
-                            if ( 'country_states' == $type ) {
42
+                            if ('country_states' == $type) {
43 43
                         
44
-                                if ( 0 == count( wpinv_get_country_states( wpinv_get_default_country() ) ) ) {
44
+                                if (0 == count(wpinv_get_country_states(wpinv_get_default_country()))) {
45 45
                                     $type = 'text';
46 46
                                 } else {
47 47
                                     $type = 'select';
@@ -50,11 +50,11 @@  discard block
 block discarded – undo
50 50
                                 $class = 'getpaid_js_field-state';
51 51
                             }
52 52
                         
53
-                            if ( 'wpinv_settings[default_country]' == $name ) {
53
+                            if ('wpinv_settings[default_country]' == $name) {
54 54
                                 $class = 'getpaid_js_field-country';
55 55
                             }
56 56
                         
57
-                            switch ( $type ) {
57
+                            switch ($type) {
58 58
                         
59 59
                                 case 'hidden':
60 60
                                     echo "<input type='hidden' id='$id' name='$name' value='$value' />";
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
                                             'type'       => $type,
67 67
                                             'id'         => $id,
68 68
                                             'name'       => $name,
69
-                                            'value'      => is_scalar( $value ) ? esc_attr( $value ) : '',
69
+                                            'value'      => is_scalar($value) ? esc_attr($value) : '',
70 70
                                             'required'   => false,
71 71
                                             'help_text'  => $help_text,
72 72
                                             'label'      => $label,
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
                                         array(
83 83
                                             'id'              => $id,
84 84
                                             'name'            => $name,
85
-                                            'value'           => is_scalar( $value ) ? esc_textarea( $value ) : '',
85
+                                            'value'           => is_scalar($value) ? esc_textarea($value) : '',
86 86
                                             'required'        => false,
87 87
                                             'help_text'       => $help_text,
88 88
                                             'label'           => $label,
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
                                     );
95 95
                         
96 96
                                     // Bug fixed in AUI 0.1.51 for name stripping []
97
-                                    echo str_replace( sanitize_html_class( $name ), esc_attr( $name ), $textarea );
97
+                                    echo str_replace(sanitize_html_class($name), esc_attr($name), $textarea);
98 98
                         
99 99
                                     break;
100 100
                                 case 'select':
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
                                             'id'              =>  $id,
104 104
                                             'name'            =>  $name,
105 105
                                             'placeholder'     => '',
106
-                                            'value'           => is_scalar( $value ) ? esc_attr( $value ) : '',
106
+                                            'value'           => is_scalar($value) ? esc_attr($value) : '',
107 107
                                             'required'        => false,
108 108
                                             'help_text'       => $help_text,
109 109
                                             'label'           => $label,
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 				<input
129 129
                     type="submit"
130 130
                     class="btn btn-primary button-next"
131
-				    value="<?php esc_attr_e( 'Continue', 'invoicing' ); ?>" name="save_step"/>
131
+				    value="<?php esc_attr_e('Continue', 'invoicing'); ?>" name="save_step"/>
132 132
 			</p>
133 133
         </table>
134 134
     </form>
Please login to merge, or discard this patch.