Passed
Pull Request — master (#388)
by Brian
05:00
created
templates/payment-forms/elements/gateway_select.php 1 patch
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -7,27 +7,27 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 // The payment methods select title.
13
-if ( empty( $text ) ) {
14
-    $text = __( 'Select Payment Method', 'invoicing' );
13
+if (empty($text)) {
14
+    $text = __('Select Payment Method', 'invoicing');
15 15
 }
16 16
 
17 17
 // An array of active payment methods.
18
-$gateways = wpinv_get_enabled_payment_gateways( true );
18
+$gateways = wpinv_get_enabled_payment_gateways(true);
19 19
 
20 20
 // Make it possible to filter active gateways.
21
-$gateways = apply_filters( 'getpaid_payment_form_gateways', $gateways, $form );
21
+$gateways = apply_filters('getpaid_payment_form_gateways', $gateways, $form);
22 22
 
23 23
 //@deprecated
24
-$gateways = apply_filters( 'wpinv_payment_gateways_on_cart', $gateways );
24
+$gateways = apply_filters('wpinv_payment_gateways_on_cart', $gateways);
25 25
 
26 26
 // The current invoice id.
27 27
 $invoice_id     = 0;
28 28
 $chosen_gateway = wpinv_get_default_gateway();
29 29
 
30
-if ( ! empty( $form->invoice ) ) {
30
+if (!empty($form->invoice)) {
31 31
     $invoice_id = $form->invoice->get_id();
32 32
     $chosen_gateway = $form->invoice->get_gateway();
33 33
 }
@@ -36,36 +36,36 @@  discard block
 block discarded – undo
36 36
 
37 37
     <div class="mt-4 mb-4">
38 38
 
39
-        <?php do_action( 'wpinv_payment_mode_top', $invoice_id, $chosen_gateway, $gateways, $form ); ?>
39
+        <?php do_action('wpinv_payment_mode_top', $invoice_id, $chosen_gateway, $gateways, $form); ?>
40 40
 
41 41
         <div class="getpaid-gateways-select-title-div">
42
-            <h6><?php echo sanitize_text_field( $text ); ?></h6>
42
+            <h6><?php echo sanitize_text_field($text); ?></h6>
43 43
         </div>
44 44
 
45 45
         
46 46
         <div class="getpaid-gateways-select-gateways-div">
47 47
 
48
-            <?php foreach ( array_keys( $gateways ) as $gateway ) : ?>
48
+            <?php foreach (array_keys($gateways) as $gateway) : ?>
49 49
 
50
-                <div class="pt-2 pb-2 getpaid-gateways-select-gateway getpaid-gateways-select-gateway-<?php echo sanitize_html_class( $gateway ) ;?>" data-checkout-label='<?php echo esc_attr( apply_filters( "getpaid_gateway_{$gateway}_checkout_button_label", '' ) ); ?>'>
50
+                <div class="pt-2 pb-2 getpaid-gateways-select-gateway getpaid-gateways-select-gateway-<?php echo sanitize_html_class($gateway); ?>" data-checkout-label='<?php echo esc_attr(apply_filters("getpaid_gateway_{$gateway}_checkout_button_label", '')); ?>'>
51 51
 
52 52
                     <div class="getpaid-gateway-radio-div">
53 53
                         <label>
54
-                            <input type="radio" value="<?php echo esc_attr( $gateway ) ;?>" <?php checked( $gateway, $chosen_gateway ) ;?> name="wpi-gateway">
55
-                            <span><?php echo sanitize_text_field( wpinv_get_gateway_checkout_label( $gateway ) ); ?></span>
54
+                            <input type="radio" value="<?php echo esc_attr($gateway); ?>" <?php checked($gateway, $chosen_gateway); ?> name="wpi-gateway">
55
+                            <span><?php echo sanitize_text_field(wpinv_get_gateway_checkout_label($gateway)); ?></span>
56 56
                         </label>
57 57
                     </div>
58 58
 
59 59
                     <div class="getpaid-gateway-description-div" style="display: none;">
60
-                        <?php do_action( 'wpinv_' . $gateway . '_checkout_fields', $invoice_id ) ;?>
61
-                        <?php if ( wpinv_get_gateway_description( $gateway ) ) : ?>
60
+                        <?php do_action('wpinv_' . $gateway . '_checkout_fields', $invoice_id); ?>
61
+                        <?php if (wpinv_get_gateway_description($gateway)) : ?>
62 62
                             <div class="getpaid-gateway-description">
63
-                                <?php echo wpinv_get_gateway_description( $gateway ); ?>
63
+                                <?php echo wpinv_get_gateway_description($gateway); ?>
64 64
                             </div>
65 65
                         <?php endif; ?>
66 66
 
67
-                        <?php do_action( 'getpaid_after_gateway_description', $invoice_id, $gateway, $form ) ;?>
68
-                        <?php do_action( 'wpinv_' . $gateway . '_cc_form', $invoice_id, $form ) ;?>
67
+                        <?php do_action('getpaid_after_gateway_description', $invoice_id, $gateway, $form); ?>
68
+                        <?php do_action('wpinv_' . $gateway . '_cc_form', $invoice_id, $form); ?>
69 69
 
70 70
                     </div>
71 71
 
@@ -76,16 +76,16 @@  discard block
 block discarded – undo
76 76
             <?php
77 77
 
78 78
 
79
-                if ( empty( $gateways ) ) {
79
+                if (empty($gateways)) {
80 80
 
81
-                    $enabled_gateways = wpinv_get_enabled_payment_gateways( true );
81
+                    $enabled_gateways = wpinv_get_enabled_payment_gateways(true);
82 82
 
83
-                    if ( ! empty( $enabled_gateways ) && $form->is_recurring() ) {
83
+                    if (!empty($enabled_gateways) && $form->is_recurring()) {
84 84
 
85 85
 
86 86
                         echo aui()->alert(
87 87
                             array(
88
-                                'content'     => __( 'Non of the available payment gateways support subscriptions.', 'invoicing' ),
88
+                                'content'     => __('Non of the available payment gateways support subscriptions.', 'invoicing'),
89 89
                                 'type'        => 'danger',
90 90
                             )
91 91
                         );
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 
96 96
                         echo aui()->alert(
97 97
                             array(
98
-                                'content'     => __( 'No active payment gateway available.', 'invoicing' ),
98
+                                'content'     => __('No active payment gateway available.', 'invoicing'),
99 99
                                 'type'        => 'danger',
100 100
                             )
101 101
                         );
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 
111 111
         </div>
112 112
 
113
-        <?php do_action( 'wpinv_payment_mode_bottom', $invoice_id, $chosen_gateway, $gateways, $form ); ?>
113
+        <?php do_action('wpinv_payment_mode_bottom', $invoice_id, $chosen_gateway, $gateways, $form); ?>
114 114
 
115 115
     </div>
116 116
 
Please login to merge, or discard this patch.
includes/class-wpinv-item.php 2 patches
Indentation   +622 added lines, -622 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 /**
@@ -10,30 +10,30 @@  discard block
 block discarded – undo
10 10
 class WPInv_Item  extends GetPaid_Data {
11 11
 
12 12
     /**
13
-	 * Which data store to load.
14
-	 *
15
-	 * @var string
16
-	 */
13
+     * Which data store to load.
14
+     *
15
+     * @var string
16
+     */
17 17
     protected $data_store_name = 'item';
18 18
 
19 19
     /**
20
-	 * This is the name of this object type.
21
-	 *
22
-	 * @var string
23
-	 */
24
-	protected $object_type = 'item';
20
+     * This is the name of this object type.
21
+     *
22
+     * @var string
23
+     */
24
+    protected $object_type = 'item';
25 25
 
26 26
     /**
27
-	 * Item Data array. This is the core item data exposed in APIs.
28
-	 *
29
-	 * @since 1.0.19
30
-	 * @var array
31
-	 */
32
-	protected $data = array(
33
-		'parent_id'            => 0,
34
-		'status'               => 'draft',
35
-		'version'              => '',
36
-		'date_created'         => null,
27
+     * Item Data array. This is the core item data exposed in APIs.
28
+     *
29
+     * @since 1.0.19
30
+     * @var array
31
+     */
32
+    protected $data = array(
33
+        'parent_id'            => 0,
34
+        'status'               => 'draft',
35
+        'version'              => '',
36
+        'date_created'         => null,
37 37
         'date_modified'        => null,
38 38
         'name'                 => '',
39 39
         'description'          => '',
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
     );
59 59
 
60 60
     /**
61
-	 * Stores meta in cache for future reads.
62
-	 *
63
-	 * A group must be set to to enable caching.
64
-	 *
65
-	 * @var string
66
-	 */
67
-	protected $cache_group = 'getpaid_items';
61
+     * Stores meta in cache for future reads.
62
+     *
63
+     * A group must be set to to enable caching.
64
+     *
65
+     * @var string
66
+     */
67
+    protected $cache_group = 'getpaid_items';
68 68
 
69 69
     /**
70 70
      * Stores a reference to the original WP_Post object
@@ -74,33 +74,33 @@  discard block
 block discarded – undo
74 74
     protected $post = null;
75 75
 
76 76
     /**
77
-	 * Get the item if ID is passed, otherwise the item is new and empty.
78
-	 *
79
-	 * @param  int|object|WPInv_Item|WP_Post $item Item to read.
80
-	 */
81
-	public function __construct( $item = 0 ) {
82
-		parent::__construct( $item );
83
-
84
-		if ( is_numeric( $item ) && $item > 0 ) {
85
-			$this->set_id( $item );
86
-		} elseif ( $item instanceof self ) {
87
-			$this->set_id( $item->get_id() );
88
-		} elseif ( ! empty( $item->ID ) ) {
89
-			$this->set_id( $item->ID );
90
-		} else {
91
-			$this->set_object_read( true );
92
-		}
77
+     * Get the item if ID is passed, otherwise the item is new and empty.
78
+     *
79
+     * @param  int|object|WPInv_Item|WP_Post $item Item to read.
80
+     */
81
+    public function __construct( $item = 0 ) {
82
+        parent::__construct( $item );
83
+
84
+        if ( is_numeric( $item ) && $item > 0 ) {
85
+            $this->set_id( $item );
86
+        } elseif ( $item instanceof self ) {
87
+            $this->set_id( $item->get_id() );
88
+        } elseif ( ! empty( $item->ID ) ) {
89
+            $this->set_id( $item->ID );
90
+        } else {
91
+            $this->set_object_read( true );
92
+        }
93 93
 
94 94
         // Load the datastore.
95
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
95
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
96 96
 
97
-		if ( $this->get_id() > 0 ) {
97
+        if ( $this->get_id() > 0 ) {
98 98
             $this->post = get_post( $this->get_id() );
99 99
             $this->ID   = $this->get_id();
100
-			$this->data_store->read( $this );
100
+            $this->data_store->read( $this );
101 101
         }
102 102
 
103
-	}
103
+    }
104 104
 
105 105
     /*
106 106
 	|--------------------------------------------------------------------------
@@ -118,379 +118,379 @@  discard block
 block discarded – undo
118 118
     */
119 119
 
120 120
     /**
121
-	 * Get parent item ID.
122
-	 *
123
-	 * @since 1.0.19
124
-	 * @param  string $context View or edit context.
125
-	 * @return int
126
-	 */
127
-	public function get_parent_id( $context = 'view' ) {
128
-		return (int) $this->get_prop( 'parent_id', $context );
121
+     * Get parent item ID.
122
+     *
123
+     * @since 1.0.19
124
+     * @param  string $context View or edit context.
125
+     * @return int
126
+     */
127
+    public function get_parent_id( $context = 'view' ) {
128
+        return (int) $this->get_prop( 'parent_id', $context );
129 129
     }
130 130
 
131 131
     /**
132
-	 * Get item status.
133
-	 *
134
-	 * @since 1.0.19
135
-	 * @param  string $context View or edit context.
136
-	 * @return string
137
-	 */
138
-	public function get_status( $context = 'view' ) {
139
-		return $this->get_prop( 'status', $context );
132
+     * Get item status.
133
+     *
134
+     * @since 1.0.19
135
+     * @param  string $context View or edit context.
136
+     * @return string
137
+     */
138
+    public function get_status( $context = 'view' ) {
139
+        return $this->get_prop( 'status', $context );
140 140
     }
141 141
 
142 142
     /**
143
-	 * Get plugin version when the item was created.
144
-	 *
145
-	 * @since 1.0.19
146
-	 * @param  string $context View or edit context.
147
-	 * @return string
148
-	 */
149
-	public function get_version( $context = 'view' ) {
150
-		return $this->get_prop( 'version', $context );
143
+     * Get plugin version when the item was created.
144
+     *
145
+     * @since 1.0.19
146
+     * @param  string $context View or edit context.
147
+     * @return string
148
+     */
149
+    public function get_version( $context = 'view' ) {
150
+        return $this->get_prop( 'version', $context );
151 151
     }
152 152
 
153 153
     /**
154
-	 * Get date when the item was created.
155
-	 *
156
-	 * @since 1.0.19
157
-	 * @param  string $context View or edit context.
158
-	 * @return string
159
-	 */
160
-	public function get_date_created( $context = 'view' ) {
161
-		return $this->get_prop( 'date_created', $context );
154
+     * Get date when the item was created.
155
+     *
156
+     * @since 1.0.19
157
+     * @param  string $context View or edit context.
158
+     * @return string
159
+     */
160
+    public function get_date_created( $context = 'view' ) {
161
+        return $this->get_prop( 'date_created', $context );
162 162
     }
163 163
 
164 164
     /**
165
-	 * Get GMT date when the item was created.
166
-	 *
167
-	 * @since 1.0.19
168
-	 * @param  string $context View or edit context.
169
-	 * @return string
170
-	 */
171
-	public function get_date_created_gmt( $context = 'view' ) {
165
+     * Get GMT date when the item was created.
166
+     *
167
+     * @since 1.0.19
168
+     * @param  string $context View or edit context.
169
+     * @return string
170
+     */
171
+    public function get_date_created_gmt( $context = 'view' ) {
172 172
         $date = $this->get_date_created( $context );
173 173
 
174 174
         if ( $date ) {
175 175
             $date = get_gmt_from_date( $date );
176 176
         }
177
-		return $date;
177
+        return $date;
178 178
     }
179 179
 
180 180
     /**
181
-	 * Get date when the item was last modified.
182
-	 *
183
-	 * @since 1.0.19
184
-	 * @param  string $context View or edit context.
185
-	 * @return string
186
-	 */
187
-	public function get_date_modified( $context = 'view' ) {
188
-		return $this->get_prop( 'date_modified', $context );
181
+     * Get date when the item was last modified.
182
+     *
183
+     * @since 1.0.19
184
+     * @param  string $context View or edit context.
185
+     * @return string
186
+     */
187
+    public function get_date_modified( $context = 'view' ) {
188
+        return $this->get_prop( 'date_modified', $context );
189 189
     }
190 190
 
191 191
     /**
192
-	 * Get GMT date when the item was last modified.
193
-	 *
194
-	 * @since 1.0.19
195
-	 * @param  string $context View or edit context.
196
-	 * @return string
197
-	 */
198
-	public function get_date_modified_gmt( $context = 'view' ) {
192
+     * Get GMT date when the item was last modified.
193
+     *
194
+     * @since 1.0.19
195
+     * @param  string $context View or edit context.
196
+     * @return string
197
+     */
198
+    public function get_date_modified_gmt( $context = 'view' ) {
199 199
         $date = $this->get_date_modified( $context );
200 200
 
201 201
         if ( $date ) {
202 202
             $date = get_gmt_from_date( $date );
203 203
         }
204
-		return $date;
204
+        return $date;
205 205
     }
206 206
 
207 207
     /**
208
-	 * Get the item name.
209
-	 *
210
-	 * @since 1.0.19
211
-	 * @param  string $context View or edit context.
212
-	 * @return string
213
-	 */
214
-	public function get_name( $context = 'view' ) {
215
-		return $this->get_prop( 'name', $context );
208
+     * Get the item name.
209
+     *
210
+     * @since 1.0.19
211
+     * @param  string $context View or edit context.
212
+     * @return string
213
+     */
214
+    public function get_name( $context = 'view' ) {
215
+        return $this->get_prop( 'name', $context );
216 216
     }
217 217
 
218 218
     /**
219
-	 * Alias of self::get_name().
220
-	 *
221
-	 * @since 1.0.19
222
-	 * @param  string $context View or edit context.
223
-	 * @return string
224
-	 */
225
-	public function get_title( $context = 'view' ) {
226
-		return $this->get_name( $context );
219
+     * Alias of self::get_name().
220
+     *
221
+     * @since 1.0.19
222
+     * @param  string $context View or edit context.
223
+     * @return string
224
+     */
225
+    public function get_title( $context = 'view' ) {
226
+        return $this->get_name( $context );
227 227
     }
228 228
 
229 229
     /**
230
-	 * Get the item description.
231
-	 *
232
-	 * @since 1.0.19
233
-	 * @param  string $context View or edit context.
234
-	 * @return string
235
-	 */
236
-	public function get_description( $context = 'view' ) {
237
-		return $this->get_prop( 'description', $context );
230
+     * Get the item description.
231
+     *
232
+     * @since 1.0.19
233
+     * @param  string $context View or edit context.
234
+     * @return string
235
+     */
236
+    public function get_description( $context = 'view' ) {
237
+        return $this->get_prop( 'description', $context );
238 238
     }
239 239
 
240 240
     /**
241
-	 * Alias of self::get_description().
242
-	 *
243
-	 * @since 1.0.19
244
-	 * @param  string $context View or edit context.
245
-	 * @return string
246
-	 */
247
-	public function get_excerpt( $context = 'view' ) {
248
-		return $this->get_description( $context );
241
+     * Alias of self::get_description().
242
+     *
243
+     * @since 1.0.19
244
+     * @param  string $context View or edit context.
245
+     * @return string
246
+     */
247
+    public function get_excerpt( $context = 'view' ) {
248
+        return $this->get_description( $context );
249 249
     }
250 250
 
251 251
     /**
252
-	 * Alias of self::get_description().
253
-	 *
254
-	 * @since 1.0.19
255
-	 * @param  string $context View or edit context.
256
-	 * @return string
257
-	 */
258
-	public function get_summary( $context = 'view' ) {
259
-		return $this->get_description( $context );
252
+     * Alias of self::get_description().
253
+     *
254
+     * @since 1.0.19
255
+     * @param  string $context View or edit context.
256
+     * @return string
257
+     */
258
+    public function get_summary( $context = 'view' ) {
259
+        return $this->get_description( $context );
260 260
     }
261 261
 
262 262
     /**
263
-	 * Get the owner of the item.
264
-	 *
265
-	 * @since 1.0.19
266
-	 * @param  string $context View or edit context.
267
-	 * @return string
268
-	 */
269
-	public function get_author( $context = 'view' ) {
270
-		return (int) $this->get_prop( 'author', $context );
263
+     * Get the owner of the item.
264
+     *
265
+     * @since 1.0.19
266
+     * @param  string $context View or edit context.
267
+     * @return string
268
+     */
269
+    public function get_author( $context = 'view' ) {
270
+        return (int) $this->get_prop( 'author', $context );
271 271
     }
272 272
 
273 273
     /**
274
-	 * Get the price of the item.
275
-	 *
276
-	 * @since 1.0.19
277
-	 * @param  string $context View or edit context.
278
-	 * @return float
279
-	 */
280
-	public function get_price( $context = 'view' ) {
274
+     * Get the price of the item.
275
+     *
276
+     * @since 1.0.19
277
+     * @param  string $context View or edit context.
278
+     * @return float
279
+     */
280
+    public function get_price( $context = 'view' ) {
281 281
         return wpinv_sanitize_amount( $this->get_prop( 'price', $context ) );
282
-	}
282
+    }
283 283
 	
284
-	/**
285
-	 * Get the inital price of the item.
286
-	 *
287
-	 * @since 1.0.19
288
-	 * @param  string $context View or edit context.
289
-	 * @return float
290
-	 */
291
-	public function get_initial_price( $context = 'view' ) {
284
+    /**
285
+     * Get the inital price of the item.
286
+     *
287
+     * @since 1.0.19
288
+     * @param  string $context View or edit context.
289
+     * @return float
290
+     */
291
+    public function get_initial_price( $context = 'view' ) {
292 292
 
293
-		$price = (float) $this->get_price( $context );
293
+        $price = (float) $this->get_price( $context );
294 294
 
295
-		if ( $this->has_free_trial() ) {
296
-			$price = 0;
297
-		}
295
+        if ( $this->has_free_trial() ) {
296
+            $price = 0;
297
+        }
298 298
 
299 299
         return wpinv_sanitize_amount( apply_filters( 'wpinv_get_initial_item_price', $price, $this ) );
300 300
     }
301 301
 
302 302
     /**
303
-	 * Returns a formated price.
304
-	 *
305
-	 * @since 1.0.19
306
-	 * @param  string $context View or edit context.
307
-	 * @return string
308
-	 */
303
+     * Returns a formated price.
304
+     *
305
+     * @since 1.0.19
306
+     * @param  string $context View or edit context.
307
+     * @return string
308
+     */
309 309
     public function get_the_price() {
310 310
         return wpinv_price( wpinv_format_amount( $this->get_price() ) );
311
-	}
312
-
313
-	/**
314
-	 * Returns the formated initial price.
315
-	 *
316
-	 * @since 1.0.19
317
-	 * @param  string $context View or edit context.
318
-	 * @return string
319
-	 */
311
+    }
312
+
313
+    /**
314
+     * Returns the formated initial price.
315
+     *
316
+     * @since 1.0.19
317
+     * @param  string $context View or edit context.
318
+     * @return string
319
+     */
320 320
     public function get_the_initial_price() {
321 321
         return wpinv_price( wpinv_format_amount( $this->get_initial_price() ) );
322 322
     }
323 323
 
324 324
     /**
325
-	 * Get the VAT rule of the item.
326
-	 *
327
-	 * @since 1.0.19
328
-	 * @param  string $context View or edit context.
329
-	 * @return string
330
-	 */
331
-	public function get_vat_rule( $context = 'view' ) {
325
+     * Get the VAT rule of the item.
326
+     *
327
+     * @since 1.0.19
328
+     * @param  string $context View or edit context.
329
+     * @return string
330
+     */
331
+    public function get_vat_rule( $context = 'view' ) {
332 332
         return $this->get_prop( 'vat_rule', $context );
333 333
     }
334 334
 
335 335
     /**
336
-	 * Get the VAT class of the item.
337
-	 *
338
-	 * @since 1.0.19
339
-	 * @param  string $context View or edit context.
340
-	 * @return string
341
-	 */
342
-	public function get_vat_class( $context = 'view' ) {
336
+     * Get the VAT class of the item.
337
+     *
338
+     * @since 1.0.19
339
+     * @param  string $context View or edit context.
340
+     * @return string
341
+     */
342
+    public function get_vat_class( $context = 'view' ) {
343 343
         return $this->get_prop( 'vat_class', $context );
344 344
     }
345 345
 
346 346
     /**
347
-	 * Get the type of the item.
348
-	 *
349
-	 * @since 1.0.19
350
-	 * @param  string $context View or edit context.
351
-	 * @return string
352
-	 */
353
-	public function get_type( $context = 'view' ) {
347
+     * Get the type of the item.
348
+     *
349
+     * @since 1.0.19
350
+     * @param  string $context View or edit context.
351
+     * @return string
352
+     */
353
+    public function get_type( $context = 'view' ) {
354 354
         return $this->get_prop( 'type', $context );
355 355
     }
356 356
 
357 357
     /**
358
-	 * Get the custom id of the item.
359
-	 *
360
-	 * @since 1.0.19
361
-	 * @param  string $context View or edit context.
362
-	 * @return string
363
-	 */
364
-	public function get_custom_id( $context = 'view' ) {
358
+     * Get the custom id of the item.
359
+     *
360
+     * @since 1.0.19
361
+     * @param  string $context View or edit context.
362
+     * @return string
363
+     */
364
+    public function get_custom_id( $context = 'view' ) {
365 365
         return $this->get_prop( 'custom_id', $context );
366 366
     }
367 367
 
368 368
     /**
369
-	 * Get the custom name of the item.
370
-	 *
371
-	 * @since 1.0.19
372
-	 * @param  string $context View or edit context.
373
-	 * @return string
374
-	 */
375
-	public function get_custom_name( $context = 'view' ) {
369
+     * Get the custom name of the item.
370
+     *
371
+     * @since 1.0.19
372
+     * @param  string $context View or edit context.
373
+     * @return string
374
+     */
375
+    public function get_custom_name( $context = 'view' ) {
376 376
         return $this->get_prop( 'custom_name', $context );
377 377
     }
378 378
 
379 379
     /**
380
-	 * Get the custom singular name of the item.
381
-	 *
382
-	 * @since 1.0.19
383
-	 * @param  string $context View or edit context.
384
-	 * @return string
385
-	 */
386
-	public function get_custom_singular_name( $context = 'view' ) {
380
+     * Get the custom singular name of the item.
381
+     *
382
+     * @since 1.0.19
383
+     * @param  string $context View or edit context.
384
+     * @return string
385
+     */
386
+    public function get_custom_singular_name( $context = 'view' ) {
387 387
         return $this->get_prop( 'custom_singular_name', $context );
388 388
     }
389 389
 
390 390
     /**
391
-	 * Checks if an item is editable..
392
-	 *
393
-	 * @since 1.0.19
394
-	 * @param  string $context View or edit context.
395
-	 * @return int
396
-	 */
397
-	public function get_is_editable( $context = 'view' ) {
391
+     * Checks if an item is editable..
392
+     *
393
+     * @since 1.0.19
394
+     * @param  string $context View or edit context.
395
+     * @return int
396
+     */
397
+    public function get_is_editable( $context = 'view' ) {
398 398
         return (int) $this->get_prop( 'is_editable', $context );
399 399
     }
400 400
 
401 401
     /**
402
-	 * Alias of self::get_is_editable().
403
-	 *
404
-	 * @since 1.0.19
405
-	 * @param  string $context View or edit context.
406
-	 * @return int
407
-	 */
408
-	public function get_editable( $context = 'view' ) {
409
-		return $this->get_is_editable( $context );
402
+     * Alias of self::get_is_editable().
403
+     *
404
+     * @since 1.0.19
405
+     * @param  string $context View or edit context.
406
+     * @return int
407
+     */
408
+    public function get_editable( $context = 'view' ) {
409
+        return $this->get_is_editable( $context );
410 410
     }
411 411
 
412 412
     /**
413
-	 * Checks if dynamic pricing is enabled.
414
-	 *
415
-	 * @since 1.0.19
416
-	 * @param  string $context View or edit context.
417
-	 * @return int
418
-	 */
419
-	public function get_is_dynamic_pricing( $context = 'view' ) {
413
+     * Checks if dynamic pricing is enabled.
414
+     *
415
+     * @since 1.0.19
416
+     * @param  string $context View or edit context.
417
+     * @return int
418
+     */
419
+    public function get_is_dynamic_pricing( $context = 'view' ) {
420 420
         return (int) $this->get_prop( 'is_dynamic_pricing', $context );
421 421
     }
422 422
 
423 423
     /**
424
-	 * Returns the minimum price if dynamic pricing is enabled.
425
-	 *
426
-	 * @since 1.0.19
427
-	 * @param  string $context View or edit context.
428
-	 * @return float
429
-	 */
430
-	public function get_minimum_price( $context = 'view' ) {
424
+     * Returns the minimum price if dynamic pricing is enabled.
425
+     *
426
+     * @since 1.0.19
427
+     * @param  string $context View or edit context.
428
+     * @return float
429
+     */
430
+    public function get_minimum_price( $context = 'view' ) {
431 431
         return wpinv_sanitize_amount( $this->get_prop( 'minimum_price', $context ) );
432 432
     }
433 433
 
434 434
     /**
435
-	 * Checks if this is a recurring item.
436
-	 *
437
-	 * @since 1.0.19
438
-	 * @param  string $context View or edit context.
439
-	 * @return int
440
-	 */
441
-	public function get_is_recurring( $context = 'view' ) {
435
+     * Checks if this is a recurring item.
436
+     *
437
+     * @since 1.0.19
438
+     * @param  string $context View or edit context.
439
+     * @return int
440
+     */
441
+    public function get_is_recurring( $context = 'view' ) {
442 442
         return (int) $this->get_prop( 'is_recurring', $context );
443
-	}
443
+    }
444 444
 	
445
-	/**
446
-	 * Get the recurring price of the item.
447
-	 *
448
-	 * @since 1.0.19
449
-	 * @param  string $context View or edit context.
450
-	 * @return float
451
-	 */
452
-	public function get_recurring_price( $context = 'view' ) {
453
-		$price = $this->get_price( $context );
445
+    /**
446
+     * Get the recurring price of the item.
447
+     *
448
+     * @since 1.0.19
449
+     * @param  string $context View or edit context.
450
+     * @return float
451
+     */
452
+    public function get_recurring_price( $context = 'view' ) {
453
+        $price = $this->get_price( $context );
454 454
         return wpinv_sanitize_amount( apply_filters( 'wpinv_get_recurring_item_price', $price, $this->ID ) );
455
-	}
456
-
457
-	/**
458
-	 * Get the first renewal date (in timestamps) of the item.
459
-	 *
460
-	 * @since 1.0.19
461
-	 * @return int
462
-	 */
463
-	public function get_first_renewal_date() {
464
-
465
-		$periods = array(
466
-			'D' => 'days',
467
-			'W' => 'weeks',
468
-			'M' => 'months',
469
-			'Y' => 'years',
470
-		);
471
-
472
-		$period   = $this->get_recurring_period();
473
-		$interval = $this->get_recurring_interval();
474
-
475
-		if ( $this->has_free_trial() ) {
476
-			$period   = $this->get_trial_period();
477
-			$interval = $this->get_trial_interval();
478
-		}
479
-
480
-		$period       = $periods[ $period ];
481
-		$interval     = empty( $interval ) ? 1 : $interval;
482
-		$next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) );
455
+    }
456
+
457
+    /**
458
+     * Get the first renewal date (in timestamps) of the item.
459
+     *
460
+     * @since 1.0.19
461
+     * @return int
462
+     */
463
+    public function get_first_renewal_date() {
464
+
465
+        $periods = array(
466
+            'D' => 'days',
467
+            'W' => 'weeks',
468
+            'M' => 'months',
469
+            'Y' => 'years',
470
+        );
471
+
472
+        $period   = $this->get_recurring_period();
473
+        $interval = $this->get_recurring_interval();
474
+
475
+        if ( $this->has_free_trial() ) {
476
+            $period   = $this->get_trial_period();
477
+            $interval = $this->get_trial_interval();
478
+        }
479
+
480
+        $period       = $periods[ $period ];
481
+        $interval     = empty( $interval ) ? 1 : $interval;
482
+        $next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) );
483 483
         return apply_filters( 'wpinv_get_first_renewal_date', $next_renewal, $this );
484 484
     }
485 485
 
486 486
     /**
487
-	 * Get the recurring period.
488
-	 *
489
-	 * @since 1.0.19
490
-	 * @param  bool $full Return abbreviation or in full.
491
-	 * @return string
492
-	 */
493
-	public function get_recurring_period( $full = false ) {
487
+     * Get the recurring period.
488
+     *
489
+     * @since 1.0.19
490
+     * @param  bool $full Return abbreviation or in full.
491
+     * @return string
492
+     */
493
+    public function get_recurring_period( $full = false ) {
494 494
         $period = $this->get_prop( 'recurring_period', 'view' );
495 495
 
496 496
         if ( $full && ! is_bool( $full ) ) {
@@ -501,63 +501,63 @@  discard block
 block discarded – undo
501 501
     }
502 502
 
503 503
     /**
504
-	 * Get the recurring interval.
505
-	 *
506
-	 * @since 1.0.19
507
-	 * @param  string $context View or edit context.
508
-	 * @return int
509
-	 */
510
-	public function get_recurring_interval( $context = 'view' ) {
511
-		$interval = absint( $this->get_prop( 'recurring_interval', $context ) );
504
+     * Get the recurring interval.
505
+     *
506
+     * @since 1.0.19
507
+     * @param  string $context View or edit context.
508
+     * @return int
509
+     */
510
+    public function get_recurring_interval( $context = 'view' ) {
511
+        $interval = absint( $this->get_prop( 'recurring_interval', $context ) );
512 512
 
513
-		if ( $interval < 1 ) {
514
-			$interval = 1;
515
-		}
513
+        if ( $interval < 1 ) {
514
+            $interval = 1;
515
+        }
516 516
 
517 517
         return $interval;
518 518
     }
519 519
 
520 520
     /**
521
-	 * Get the recurring limit.
522
-	 *
523
-	 * @since 1.0.19
524
-	 * @param  string $context View or edit context.
525
-	 * @return int
526
-	 */
527
-	public function get_recurring_limit( $context = 'view' ) {
521
+     * Get the recurring limit.
522
+     *
523
+     * @since 1.0.19
524
+     * @param  string $context View or edit context.
525
+     * @return int
526
+     */
527
+    public function get_recurring_limit( $context = 'view' ) {
528 528
         return (int) $this->get_prop( 'recurring_limit', $context );
529 529
     }
530 530
 
531 531
     /**
532
-	 * Checks if we have a free trial.
533
-	 *
534
-	 * @since 1.0.19
535
-	 * @param  string $context View or edit context.
536
-	 * @return int
537
-	 */
538
-	public function get_is_free_trial( $context = 'view' ) {
532
+     * Checks if we have a free trial.
533
+     *
534
+     * @since 1.0.19
535
+     * @param  string $context View or edit context.
536
+     * @return int
537
+     */
538
+    public function get_is_free_trial( $context = 'view' ) {
539 539
         return (int) $this->get_prop( 'is_free_trial', $context );
540 540
     }
541 541
 
542 542
     /**
543
-	 * Alias for self::get_is_free_trial().
544
-	 *
545
-	 * @since 1.0.19
546
-	 * @param  string $context View or edit context.
547
-	 * @return int
548
-	 */
549
-	public function get_free_trial( $context = 'view' ) {
543
+     * Alias for self::get_is_free_trial().
544
+     *
545
+     * @since 1.0.19
546
+     * @param  string $context View or edit context.
547
+     * @return int
548
+     */
549
+    public function get_free_trial( $context = 'view' ) {
550 550
         return $this->get_is_free_trial( $context );
551 551
     }
552 552
 
553 553
     /**
554
-	 * Get the trial period.
555
-	 *
556
-	 * @since 1.0.19
557
-	 * @param  bool $full Return abbreviation or in full.
558
-	 * @return string
559
-	 */
560
-	public function get_trial_period( $full = false ) {
554
+     * Get the trial period.
555
+     *
556
+     * @since 1.0.19
557
+     * @param  bool $full Return abbreviation or in full.
558
+     * @return string
559
+     */
560
+    public function get_trial_period( $full = false ) {
561 561
         $period = $this->get_prop( 'trial_period', 'view' );
562 562
 
563 563
         if ( $full && ! is_bool( $full ) ) {
@@ -568,25 +568,25 @@  discard block
 block discarded – undo
568 568
     }
569 569
 
570 570
     /**
571
-	 * Get the trial interval.
572
-	 *
573
-	 * @since 1.0.19
574
-	 * @param  string $context View or edit context.
575
-	 * @return int
576
-	 */
577
-	public function get_trial_interval( $context = 'view' ) {
571
+     * Get the trial interval.
572
+     *
573
+     * @since 1.0.19
574
+     * @param  string $context View or edit context.
575
+     * @return int
576
+     */
577
+    public function get_trial_interval( $context = 'view' ) {
578 578
         return (int) $this->get_prop( 'trial_interval', $context );
579
-	}
579
+    }
580 580
 	
581
-	/**
582
-	 * Get the item's edit url.
583
-	 *
584
-	 * @since 1.0.19
585
-	 * @return string
586
-	 */
587
-	public function get_edit_url() {
581
+    /**
582
+     * Get the item's edit url.
583
+     *
584
+     * @since 1.0.19
585
+     * @return string
586
+     */
587
+    public function get_edit_url() {
588 588
         return get_edit_post_link( $this->get_id() );
589
-	}
589
+    }
590 590
 
591 591
     /**
592 592
      * Margic method for retrieving a property.
@@ -618,52 +618,52 @@  discard block
 block discarded – undo
618 618
     */
619 619
 
620 620
     /**
621
-	 * Set parent order ID.
622
-	 *
623
-	 * @since 1.0.19
624
-	 */
625
-	public function set_parent_id( $value ) {
626
-		if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) {
627
-			return;
628
-		}
629
-		$this->set_prop( 'parent_id', absint( $value ) );
630
-	}
631
-
632
-    /**
633
-	 * Sets item status.
634
-	 *
635
-	 * @since 1.0.19
636
-	 * @param  string $status New status.
637
-	 * @return array details of change.
638
-	 */
639
-	public function set_status( $status ) {
621
+     * Set parent order ID.
622
+     *
623
+     * @since 1.0.19
624
+     */
625
+    public function set_parent_id( $value ) {
626
+        if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) {
627
+            return;
628
+        }
629
+        $this->set_prop( 'parent_id', absint( $value ) );
630
+    }
631
+
632
+    /**
633
+     * Sets item status.
634
+     *
635
+     * @since 1.0.19
636
+     * @param  string $status New status.
637
+     * @return array details of change.
638
+     */
639
+    public function set_status( $status ) {
640 640
         $old_status = $this->get_status();
641 641
 
642 642
         $this->set_prop( 'status', $status );
643 643
 
644
-		return array(
645
-			'from' => $old_status,
646
-			'to'   => $status,
647
-		);
644
+        return array(
645
+            'from' => $old_status,
646
+            'to'   => $status,
647
+        );
648 648
     }
649 649
 
650 650
     /**
651
-	 * Set plugin version when the item was created.
652
-	 *
653
-	 * @since 1.0.19
654
-	 */
655
-	public function set_version( $value ) {
656
-		$this->set_prop( 'version', $value );
651
+     * Set plugin version when the item was created.
652
+     *
653
+     * @since 1.0.19
654
+     */
655
+    public function set_version( $value ) {
656
+        $this->set_prop( 'version', $value );
657 657
     }
658 658
 
659 659
     /**
660
-	 * Set date when the item was created.
661
-	 *
662
-	 * @since 1.0.19
663
-	 * @param string $value Value to set.
660
+     * Set date when the item was created.
661
+     *
662
+     * @since 1.0.19
663
+     * @param string $value Value to set.
664 664
      * @return bool Whether or not the date was set.
665
-	 */
666
-	public function set_date_created( $value ) {
665
+     */
666
+    public function set_date_created( $value ) {
667 667
         $date = strtotime( $value );
668 668
 
669 669
         if ( $date ) {
@@ -676,13 +676,13 @@  discard block
 block discarded – undo
676 676
     }
677 677
 
678 678
     /**
679
-	 * Set date when the item was last modified.
680
-	 *
681
-	 * @since 1.0.19
682
-	 * @param string $value Value to set.
679
+     * Set date when the item was last modified.
680
+     *
681
+     * @since 1.0.19
682
+     * @param string $value Value to set.
683 683
      * @return bool Whether or not the date was set.
684
-	 */
685
-	public function set_date_modified( $value ) {
684
+     */
685
+    public function set_date_modified( $value ) {
686 686
         $date = strtotime( $value );
687 687
 
688 688
         if ( $date ) {
@@ -695,105 +695,105 @@  discard block
 block discarded – undo
695 695
     }
696 696
 
697 697
     /**
698
-	 * Set the item name.
699
-	 *
700
-	 * @since 1.0.19
701
-	 * @param  string $value New name.
702
-	 */
703
-	public function set_name( $value ) {
698
+     * Set the item name.
699
+     *
700
+     * @since 1.0.19
701
+     * @param  string $value New name.
702
+     */
703
+    public function set_name( $value ) {
704 704
         $name = sanitize_text_field( $value );
705
-		$this->set_prop( 'name', $name );
705
+        $this->set_prop( 'name', $name );
706 706
     }
707 707
 
708 708
     /**
709
-	 * Alias of self::set_name().
710
-	 *
711
-	 * @since 1.0.19
712
-	 * @param  string $value New name.
713
-	 */
714
-	public function set_title( $value ) {
715
-		$this->set_name( $value );
709
+     * Alias of self::set_name().
710
+     *
711
+     * @since 1.0.19
712
+     * @param  string $value New name.
713
+     */
714
+    public function set_title( $value ) {
715
+        $this->set_name( $value );
716 716
     }
717 717
 
718 718
     /**
719
-	 * Set the item description.
720
-	 *
721
-	 * @since 1.0.19
722
-	 * @param  string $value New description.
723
-	 */
724
-	public function set_description( $value ) {
719
+     * Set the item description.
720
+     *
721
+     * @since 1.0.19
722
+     * @param  string $value New description.
723
+     */
724
+    public function set_description( $value ) {
725 725
         $description = wp_kses_post( $value );
726
-		return $this->set_prop( 'description', $description );
726
+        return $this->set_prop( 'description', $description );
727 727
     }
728 728
 
729 729
     /**
730
-	 * Alias of self::set_description().
731
-	 *
732
-	 * @since 1.0.19
733
-	 * @param  string $value New description.
734
-	 */
735
-	public function set_excerpt( $value ) {
736
-		$this->set_description( $value );
730
+     * Alias of self::set_description().
731
+     *
732
+     * @since 1.0.19
733
+     * @param  string $value New description.
734
+     */
735
+    public function set_excerpt( $value ) {
736
+        $this->set_description( $value );
737 737
     }
738 738
 
739 739
     /**
740
-	 * Alias of self::set_description().
741
-	 *
742
-	 * @since 1.0.19
743
-	 * @param  string $value New description.
744
-	 */
745
-	public function set_summary( $value ) {
746
-		$this->set_description( $value );
740
+     * Alias of self::set_description().
741
+     *
742
+     * @since 1.0.19
743
+     * @param  string $value New description.
744
+     */
745
+    public function set_summary( $value ) {
746
+        $this->set_description( $value );
747 747
     }
748 748
 
749 749
     /**
750
-	 * Set the owner of the item.
751
-	 *
752
-	 * @since 1.0.19
753
-	 * @param  int $value New author.
754
-	 */
755
-	public function set_author( $value ) {
756
-		$this->set_prop( 'author', (int) $value );
750
+     * Set the owner of the item.
751
+     *
752
+     * @since 1.0.19
753
+     * @param  int $value New author.
754
+     */
755
+    public function set_author( $value ) {
756
+        $this->set_prop( 'author', (int) $value );
757 757
     }
758 758
 
759 759
     /**
760
-	 * Set the price of the item.
761
-	 *
762
-	 * @since 1.0.19
763
-	 * @param  float $value New price.
764
-	 */
765
-	public function set_price( $value ) {
760
+     * Set the price of the item.
761
+     *
762
+     * @since 1.0.19
763
+     * @param  float $value New price.
764
+     */
765
+    public function set_price( $value ) {
766 766
         $this->set_prop( 'price', (float) wpinv_sanitize_amount( $value ) );
767 767
     }
768 768
 
769 769
     /**
770
-	 * Set the VAT rule of the item.
771
-	 *
772
-	 * @since 1.0.19
773
-	 * @param  string $value new rule.
774
-	 */
775
-	public function set_vat_rule( $value ) {
770
+     * Set the VAT rule of the item.
771
+     *
772
+     * @since 1.0.19
773
+     * @param  string $value new rule.
774
+     */
775
+    public function set_vat_rule( $value ) {
776 776
         $this->set_prop( 'vat_rule', $value );
777 777
     }
778 778
 
779 779
     /**
780
-	 * Set the VAT class of the item.
781
-	 *
782
-	 * @since 1.0.19
783
-	 * @param  string $value new class.
784
-	 */
785
-	public function set_vat_class( $value ) {
780
+     * Set the VAT class of the item.
781
+     *
782
+     * @since 1.0.19
783
+     * @param  string $value new class.
784
+     */
785
+    public function set_vat_class( $value ) {
786 786
         $this->set_prop( 'vat_class', $value );
787 787
     }
788 788
 
789 789
     /**
790
-	 * Set the type of the item.
791
-	 *
792
-	 * @since 1.0.19
793
-	 * @param  string $value new item type.
794
-	 * @return string
795
-	 */
796
-	public function set_type( $value ) {
790
+     * Set the type of the item.
791
+     *
792
+     * @since 1.0.19
793
+     * @param  string $value new item type.
794
+     * @return string
795
+     */
796
+    public function set_type( $value ) {
797 797
 
798 798
         if ( empty( $value ) ) {
799 799
             $value = 'custom';
@@ -803,134 +803,134 @@  discard block
 block discarded – undo
803 803
     }
804 804
 
805 805
     /**
806
-	 * Set the custom id of the item.
807
-	 *
808
-	 * @since 1.0.19
809
-	 * @param  string $value new custom id.
810
-	 */
811
-	public function set_custom_id( $value ) {
806
+     * Set the custom id of the item.
807
+     *
808
+     * @since 1.0.19
809
+     * @param  string $value new custom id.
810
+     */
811
+    public function set_custom_id( $value ) {
812 812
         $this->set_prop( 'custom_id', $value );
813 813
     }
814 814
 
815 815
     /**
816
-	 * Set the custom name of the item.
817
-	 *
818
-	 * @since 1.0.19
819
-	 * @param  string $value new custom name.
820
-	 */
821
-	public function set_custom_name( $value ) {
816
+     * Set the custom name of the item.
817
+     *
818
+     * @since 1.0.19
819
+     * @param  string $value new custom name.
820
+     */
821
+    public function set_custom_name( $value ) {
822 822
         $this->set_prop( 'custom_name', $value );
823 823
     }
824 824
 
825 825
     /**
826
-	 * Set the custom singular name of the item.
827
-	 *
828
-	 * @since 1.0.19
829
-	 * @param  string $value new custom singular name.
830
-	 */
831
-	public function set_custom_singular_name( $value ) {
826
+     * Set the custom singular name of the item.
827
+     *
828
+     * @since 1.0.19
829
+     * @param  string $value new custom singular name.
830
+     */
831
+    public function set_custom_singular_name( $value ) {
832 832
         $this->set_prop( 'custom_singular_name', $value );
833 833
     }
834 834
 
835 835
     /**
836
-	 * Sets if an item is editable..
837
-	 *
838
-	 * @since 1.0.19
839
-	 * @param  int|bool $value whether or not the item is editable.
840
-	 */
841
-	public function set_is_editable( $value ) {
842
-		if ( is_numeric( $value ) ) {
843
-			$this->set_prop( 'is_editable', (int) $value );
844
-		}
836
+     * Sets if an item is editable..
837
+     *
838
+     * @since 1.0.19
839
+     * @param  int|bool $value whether or not the item is editable.
840
+     */
841
+    public function set_is_editable( $value ) {
842
+        if ( is_numeric( $value ) ) {
843
+            $this->set_prop( 'is_editable', (int) $value );
844
+        }
845 845
     }
846 846
 
847 847
     /**
848
-	 * Sets if dynamic pricing is enabled.
849
-	 *
850
-	 * @since 1.0.19
851
-	 * @param  int|bool $value whether or not dynamic pricing is allowed.
852
-	 */
853
-	public function set_is_dynamic_pricing( $value ) {
848
+     * Sets if dynamic pricing is enabled.
849
+     *
850
+     * @since 1.0.19
851
+     * @param  int|bool $value whether or not dynamic pricing is allowed.
852
+     */
853
+    public function set_is_dynamic_pricing( $value ) {
854 854
         $this->set_prop( 'is_dynamic_pricing', (int) $value );
855 855
     }
856 856
 
857 857
     /**
858
-	 * Sets the minimum price if dynamic pricing is enabled.
859
-	 *
860
-	 * @since 1.0.19
861
-	 * @param  float $value minimum price.
862
-	 */
863
-	public function set_minimum_price( $value ) {
858
+     * Sets the minimum price if dynamic pricing is enabled.
859
+     *
860
+     * @since 1.0.19
861
+     * @param  float $value minimum price.
862
+     */
863
+    public function set_minimum_price( $value ) {
864 864
         $this->set_prop( 'minimum_price',  (float) wpinv_sanitize_amount( $value ) );
865 865
     }
866 866
 
867 867
     /**
868
-	 * Sets if this is a recurring item.
869
-	 *
870
-	 * @since 1.0.19
871
-	 * @param  int|bool $value whether or not dynamic pricing is allowed.
872
-	 */
873
-	public function set_is_recurring( $value ) {
868
+     * Sets if this is a recurring item.
869
+     *
870
+     * @since 1.0.19
871
+     * @param  int|bool $value whether or not dynamic pricing is allowed.
872
+     */
873
+    public function set_is_recurring( $value ) {
874 874
         $this->set_prop( 'is_recurring', (int) $value );
875 875
     }
876 876
 
877 877
     /**
878
-	 * Set the recurring period.
879
-	 *
880
-	 * @since 1.0.19
881
-	 * @param  string $value new period.
882
-	 */
883
-	public function set_recurring_period( $value ) {
878
+     * Set the recurring period.
879
+     *
880
+     * @since 1.0.19
881
+     * @param  string $value new period.
882
+     */
883
+    public function set_recurring_period( $value ) {
884 884
         $this->set_prop( 'recurring_period', $value );
885 885
     }
886 886
 
887 887
     /**
888
-	 * Set the recurring interval.
889
-	 *
890
-	 * @since 1.0.19
891
-	 * @param  int $value recurring interval.
892
-	 */
893
-	public function set_recurring_interval( $value ) {
888
+     * Set the recurring interval.
889
+     *
890
+     * @since 1.0.19
891
+     * @param  int $value recurring interval.
892
+     */
893
+    public function set_recurring_interval( $value ) {
894 894
         return $this->set_prop( 'recurring_interval', (int) $value );
895 895
     }
896 896
 
897 897
     /**
898
-	 * Get the recurring limit.
899
-	 * @since 1.0.19
900
-	 * @param  int $value The recurring limit.
901
-	 * @return int
902
-	 */
903
-	public function set_recurring_limit( $value ) {
898
+     * Get the recurring limit.
899
+     * @since 1.0.19
900
+     * @param  int $value The recurring limit.
901
+     * @return int
902
+     */
903
+    public function set_recurring_limit( $value ) {
904 904
         $this->set_prop( 'recurring_limit', (int) $value );
905 905
     }
906 906
 
907 907
     /**
908
-	 * Checks if we have a free trial.
909
-	 *
910
-	 * @since 1.0.19
911
-	 * @param  int|bool $value whether or not it has a free trial.
912
-	 */
913
-	public function set_is_free_trial( $value ) {
908
+     * Checks if we have a free trial.
909
+     *
910
+     * @since 1.0.19
911
+     * @param  int|bool $value whether or not it has a free trial.
912
+     */
913
+    public function set_is_free_trial( $value ) {
914 914
         $this->set_prop( 'is_free_trial', (int) $value );
915 915
     }
916 916
 
917 917
     /**
918
-	 * Set the trial period.
919
-	 *
920
-	 * @since 1.0.19
921
-	 * @param  string $value trial period.
922
-	 */
923
-	public function set_trial_period( $value ) {
918
+     * Set the trial period.
919
+     *
920
+     * @since 1.0.19
921
+     * @param  string $value trial period.
922
+     */
923
+    public function set_trial_period( $value ) {
924 924
         $this->set_prop( 'trial_period', $value );
925 925
     }
926 926
 
927 927
     /**
928
-	 * Set the trial interval.
929
-	 *
930
-	 * @since 1.0.19
931
-	 * @param  int $value trial interval.
932
-	 */
933
-	public function set_trial_interval( $value ) {
928
+     * Set the trial interval.
929
+     *
930
+     * @since 1.0.19
931
+     * @param  int $value trial interval.
932
+     */
933
+    public function set_trial_interval( $value ) {
934 934
         $this->set_prop( 'trial_interval', $value );
935 935
     }
936 936
 
@@ -938,17 +938,17 @@  discard block
 block discarded – undo
938 938
      * Create an item. For backwards compatibilty.
939 939
      * 
940 940
      * @deprecated
941
-	 * @return int item id
941
+     * @return int item id
942 942
      */
943 943
     public function create( $data = array() ) {
944 944
 
945
-		// Set the properties.
946
-		if ( is_array( $data ) ) {
947
-			$this->set_props( $data );
948
-		}
945
+        // Set the properties.
946
+        if ( is_array( $data ) ) {
947
+            $this->set_props( $data );
948
+        }
949 949
 
950
-		// Save the item.
951
-		return $this->save();
950
+        // Save the item.
951
+        return $this->save();
952 952
 
953 953
     }
954 954
 
@@ -956,7 +956,7 @@  discard block
 block discarded – undo
956 956
      * Updates an item. For backwards compatibilty.
957 957
      * 
958 958
      * @deprecated
959
-	 * @return int item id
959
+     * @return int item id
960 960
      */
961 961
     public function update( $data = array() ) {
962 962
         return $this->create( $data );
@@ -972,84 +972,84 @@  discard block
 block discarded – undo
972 972
 	*/
973 973
 
974 974
     /**
975
-	 * Checks whether the item has enabled dynamic pricing.
976
-	 *
977
-	 * @since 1.0.19
978
-	 * @return bool
979
-	 */
980
-	public function user_can_set_their_price() {
975
+     * Checks whether the item has enabled dynamic pricing.
976
+     *
977
+     * @since 1.0.19
978
+     * @return bool
979
+     */
980
+    public function user_can_set_their_price() {
981 981
         return (bool) $this->get_is_dynamic_pricing();
982
-	}
982
+    }
983 983
 	
984
-	/**
985
-	 * Checks whether the item is recurring.
986
-	 *
987
-	 * @since 1.0.19
988
-	 * @return bool
989
-	 */
990
-	public function is_recurring() {
984
+    /**
985
+     * Checks whether the item is recurring.
986
+     *
987
+     * @since 1.0.19
988
+     * @return bool
989
+     */
990
+    public function is_recurring() {
991 991
         return (bool) $this->get_is_recurring();
992 992
     }
993 993
 
994 994
     /**
995
-	 * Checks whether the item has a free trial.
996
-	 *
997
-	 * @since 1.0.19
998
-	 * @return bool
999
-	 */
995
+     * Checks whether the item has a free trial.
996
+     *
997
+     * @since 1.0.19
998
+     * @return bool
999
+     */
1000 1000
     public function has_free_trial() {
1001 1001
         $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false;
1002 1002
         return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this );
1003 1003
     }
1004 1004
 
1005 1005
     /**
1006
-	 * Checks whether the item is free.
1007
-	 *
1008
-	 * @since 1.0.19
1009
-	 * @return bool
1010
-	 */
1006
+     * Checks whether the item is free.
1007
+     *
1008
+     * @since 1.0.19
1009
+     * @return bool
1010
+     */
1011 1011
     public function is_free() {
1012 1012
         $is_free   = $this->get_price() == 0;
1013 1013
         return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this );
1014 1014
     }
1015 1015
 
1016 1016
     /**
1017
-	 * Checks the item status against a passed in status.
1018
-	 *
1019
-	 * @param array|string $status Status to check.
1020
-	 * @return bool
1021
-	 */
1022
-	public function has_status( $status ) {
1023
-		$has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status;
1024
-		return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status );
1017
+     * Checks the item status against a passed in status.
1018
+     *
1019
+     * @param array|string $status Status to check.
1020
+     * @return bool
1021
+     */
1022
+    public function has_status( $status ) {
1023
+        $has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status;
1024
+        return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status );
1025 1025
     }
1026 1026
 
1027 1027
     /**
1028
-	 * Checks the item type against a passed in types.
1029
-	 *
1030
-	 * @param array|string $type Type to check.
1031
-	 * @return bool
1032
-	 */
1033
-	public function is_type( $type ) {
1034
-		$is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type;
1035
-		return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type );
1036
-	}
1028
+     * Checks the item type against a passed in types.
1029
+     *
1030
+     * @param array|string $type Type to check.
1031
+     * @return bool
1032
+     */
1033
+    public function is_type( $type ) {
1034
+        $is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type;
1035
+        return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type );
1036
+    }
1037 1037
 
1038 1038
     /**
1039
-	 * Checks whether the item is editable.
1040
-	 *
1041
-	 * @since 1.0.19
1042
-	 * @return bool
1043
-	 */
1039
+     * Checks whether the item is editable.
1040
+     *
1041
+     * @since 1.0.19
1042
+     * @return bool
1043
+     */
1044 1044
     public function is_editable() {
1045 1045
         $is_editable = $this->get_is_editable();
1046 1046
         return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this );
1047
-	}
1047
+    }
1048 1048
 
1049
-	/**
1050
-	 * Returns an array of cart fees.
1051
-	 */
1052
-	public function get_fees( $type = 'fee', $item_id = 0 ) {
1049
+    /**
1050
+     * Returns an array of cart fees.
1051
+     */
1052
+    public function get_fees( $type = 'fee', $item_id = 0 ) {
1053 1053
         global $wpi_session;
1054 1054
         
1055 1055
         $fees = $wpi_session->get( 'wpi_cart_fees' );
@@ -1093,11 +1093,11 @@  discard block
 block discarded – undo
1093 1093
     }
1094 1094
 
1095 1095
     /**
1096
-	 * Checks whether the item is purchasable.
1097
-	 *
1098
-	 * @since 1.0.19
1099
-	 * @return bool
1100
-	 */
1096
+     * Checks whether the item is purchasable.
1097
+     *
1098
+     * @since 1.0.19
1099
+     * @return bool
1100
+     */
1101 1101
     public function can_purchase() {
1102 1102
         $can_purchase = null !== $this->get_id();
1103 1103
 
@@ -1109,11 +1109,11 @@  discard block
 block discarded – undo
1109 1109
     }
1110 1110
 
1111 1111
     /**
1112
-	 * Checks whether the item supports dynamic pricing.
1113
-	 *
1114
-	 * @since 1.0.19
1115
-	 * @return bool
1116
-	 */
1112
+     * Checks whether the item supports dynamic pricing.
1113
+     *
1114
+     * @since 1.0.19
1115
+     * @return bool
1116
+     */
1117 1117
     public function supports_dynamic_pricing() {
1118 1118
         return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this );
1119 1119
     }
Please login to merge, or discard this patch.
Spacing   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -78,26 +78,26 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @param  int|object|WPInv_Item|WP_Post $item Item to read.
80 80
 	 */
81
-	public function __construct( $item = 0 ) {
82
-		parent::__construct( $item );
81
+	public function __construct($item = 0) {
82
+		parent::__construct($item);
83 83
 
84
-		if ( is_numeric( $item ) && $item > 0 ) {
85
-			$this->set_id( $item );
86
-		} elseif ( $item instanceof self ) {
87
-			$this->set_id( $item->get_id() );
88
-		} elseif ( ! empty( $item->ID ) ) {
89
-			$this->set_id( $item->ID );
84
+		if (is_numeric($item) && $item > 0) {
85
+			$this->set_id($item);
86
+		} elseif ($item instanceof self) {
87
+			$this->set_id($item->get_id());
88
+		} elseif (!empty($item->ID)) {
89
+			$this->set_id($item->ID);
90 90
 		} else {
91
-			$this->set_object_read( true );
91
+			$this->set_object_read(true);
92 92
 		}
93 93
 
94 94
         // Load the datastore.
95
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
95
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
96 96
 
97
-		if ( $this->get_id() > 0 ) {
98
-            $this->post = get_post( $this->get_id() );
97
+		if ($this->get_id() > 0) {
98
+            $this->post = get_post($this->get_id());
99 99
             $this->ID   = $this->get_id();
100
-			$this->data_store->read( $this );
100
+			$this->data_store->read($this);
101 101
         }
102 102
 
103 103
 	}
@@ -124,8 +124,8 @@  discard block
 block discarded – undo
124 124
 	 * @param  string $context View or edit context.
125 125
 	 * @return int
126 126
 	 */
127
-	public function get_parent_id( $context = 'view' ) {
128
-		return (int) $this->get_prop( 'parent_id', $context );
127
+	public function get_parent_id($context = 'view') {
128
+		return (int) $this->get_prop('parent_id', $context);
129 129
     }
130 130
 
131 131
     /**
@@ -135,8 +135,8 @@  discard block
 block discarded – undo
135 135
 	 * @param  string $context View or edit context.
136 136
 	 * @return string
137 137
 	 */
138
-	public function get_status( $context = 'view' ) {
139
-		return $this->get_prop( 'status', $context );
138
+	public function get_status($context = 'view') {
139
+		return $this->get_prop('status', $context);
140 140
     }
141 141
 
142 142
     /**
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 	 * @param  string $context View or edit context.
147 147
 	 * @return string
148 148
 	 */
149
-	public function get_version( $context = 'view' ) {
150
-		return $this->get_prop( 'version', $context );
149
+	public function get_version($context = 'view') {
150
+		return $this->get_prop('version', $context);
151 151
     }
152 152
 
153 153
     /**
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
 	 * @param  string $context View or edit context.
158 158
 	 * @return string
159 159
 	 */
160
-	public function get_date_created( $context = 'view' ) {
161
-		return $this->get_prop( 'date_created', $context );
160
+	public function get_date_created($context = 'view') {
161
+		return $this->get_prop('date_created', $context);
162 162
     }
163 163
 
164 164
     /**
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
 	 * @param  string $context View or edit context.
169 169
 	 * @return string
170 170
 	 */
171
-	public function get_date_created_gmt( $context = 'view' ) {
172
-        $date = $this->get_date_created( $context );
171
+	public function get_date_created_gmt($context = 'view') {
172
+        $date = $this->get_date_created($context);
173 173
 
174
-        if ( $date ) {
175
-            $date = get_gmt_from_date( $date );
174
+        if ($date) {
175
+            $date = get_gmt_from_date($date);
176 176
         }
177 177
 		return $date;
178 178
     }
@@ -184,8 +184,8 @@  discard block
 block discarded – undo
184 184
 	 * @param  string $context View or edit context.
185 185
 	 * @return string
186 186
 	 */
187
-	public function get_date_modified( $context = 'view' ) {
188
-		return $this->get_prop( 'date_modified', $context );
187
+	public function get_date_modified($context = 'view') {
188
+		return $this->get_prop('date_modified', $context);
189 189
     }
190 190
 
191 191
     /**
@@ -195,11 +195,11 @@  discard block
 block discarded – undo
195 195
 	 * @param  string $context View or edit context.
196 196
 	 * @return string
197 197
 	 */
198
-	public function get_date_modified_gmt( $context = 'view' ) {
199
-        $date = $this->get_date_modified( $context );
198
+	public function get_date_modified_gmt($context = 'view') {
199
+        $date = $this->get_date_modified($context);
200 200
 
201
-        if ( $date ) {
202
-            $date = get_gmt_from_date( $date );
201
+        if ($date) {
202
+            $date = get_gmt_from_date($date);
203 203
         }
204 204
 		return $date;
205 205
     }
@@ -211,8 +211,8 @@  discard block
 block discarded – undo
211 211
 	 * @param  string $context View or edit context.
212 212
 	 * @return string
213 213
 	 */
214
-	public function get_name( $context = 'view' ) {
215
-		return $this->get_prop( 'name', $context );
214
+	public function get_name($context = 'view') {
215
+		return $this->get_prop('name', $context);
216 216
     }
217 217
 
218 218
     /**
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
 	 * @param  string $context View or edit context.
223 223
 	 * @return string
224 224
 	 */
225
-	public function get_title( $context = 'view' ) {
226
-		return $this->get_name( $context );
225
+	public function get_title($context = 'view') {
226
+		return $this->get_name($context);
227 227
     }
228 228
 
229 229
     /**
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
 	 * @param  string $context View or edit context.
234 234
 	 * @return string
235 235
 	 */
236
-	public function get_description( $context = 'view' ) {
237
-		return $this->get_prop( 'description', $context );
236
+	public function get_description($context = 'view') {
237
+		return $this->get_prop('description', $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 string
246 246
 	 */
247
-	public function get_excerpt( $context = 'view' ) {
248
-		return $this->get_description( $context );
247
+	public function get_excerpt($context = 'view') {
248
+		return $this->get_description($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 string
257 257
 	 */
258
-	public function get_summary( $context = 'view' ) {
259
-		return $this->get_description( $context );
258
+	public function get_summary($context = 'view') {
259
+		return $this->get_description($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 string
268 268
 	 */
269
-	public function get_author( $context = 'view' ) {
270
-		return (int) $this->get_prop( 'author', $context );
269
+	public function get_author($context = 'view') {
270
+		return (int) $this->get_prop('author', $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 float
279 279
 	 */
280
-	public function get_price( $context = 'view' ) {
281
-        return wpinv_sanitize_amount( $this->get_prop( 'price', $context ) );
280
+	public function get_price($context = 'view') {
281
+        return wpinv_sanitize_amount($this->get_prop('price', $context));
282 282
 	}
283 283
 	
284 284
 	/**
@@ -288,15 +288,15 @@  discard block
 block discarded – undo
288 288
 	 * @param  string $context View or edit context.
289 289
 	 * @return float
290 290
 	 */
291
-	public function get_initial_price( $context = 'view' ) {
291
+	public function get_initial_price($context = 'view') {
292 292
 
293
-		$price = (float) $this->get_price( $context );
293
+		$price = (float) $this->get_price($context);
294 294
 
295
-		if ( $this->has_free_trial() ) {
295
+		if ($this->has_free_trial()) {
296 296
 			$price = 0;
297 297
 		}
298 298
 
299
-        return wpinv_sanitize_amount( apply_filters( 'wpinv_get_initial_item_price', $price, $this ) );
299
+        return wpinv_sanitize_amount(apply_filters('wpinv_get_initial_item_price', $price, $this));
300 300
     }
301 301
 
302 302
     /**
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
 	 * @return string
308 308
 	 */
309 309
     public function get_the_price() {
310
-        return wpinv_price( wpinv_format_amount( $this->get_price() ) );
310
+        return wpinv_price(wpinv_format_amount($this->get_price()));
311 311
 	}
312 312
 
313 313
 	/**
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 	 * @return string
319 319
 	 */
320 320
     public function get_the_initial_price() {
321
-        return wpinv_price( wpinv_format_amount( $this->get_initial_price() ) );
321
+        return wpinv_price(wpinv_format_amount($this->get_initial_price()));
322 322
     }
323 323
 
324 324
     /**
@@ -328,8 +328,8 @@  discard block
 block discarded – undo
328 328
 	 * @param  string $context View or edit context.
329 329
 	 * @return string
330 330
 	 */
331
-	public function get_vat_rule( $context = 'view' ) {
332
-        return $this->get_prop( 'vat_rule', $context );
331
+	public function get_vat_rule($context = 'view') {
332
+        return $this->get_prop('vat_rule', $context);
333 333
     }
334 334
 
335 335
     /**
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
 	 * @param  string $context View or edit context.
340 340
 	 * @return string
341 341
 	 */
342
-	public function get_vat_class( $context = 'view' ) {
343
-        return $this->get_prop( 'vat_class', $context );
342
+	public function get_vat_class($context = 'view') {
343
+        return $this->get_prop('vat_class', $context);
344 344
     }
345 345
 
346 346
     /**
@@ -350,8 +350,8 @@  discard block
 block discarded – undo
350 350
 	 * @param  string $context View or edit context.
351 351
 	 * @return string
352 352
 	 */
353
-	public function get_type( $context = 'view' ) {
354
-        return $this->get_prop( 'type', $context );
353
+	public function get_type($context = 'view') {
354
+        return $this->get_prop('type', $context);
355 355
     }
356 356
 
357 357
     /**
@@ -361,8 +361,8 @@  discard block
 block discarded – undo
361 361
 	 * @param  string $context View or edit context.
362 362
 	 * @return string
363 363
 	 */
364
-	public function get_custom_id( $context = 'view' ) {
365
-        return $this->get_prop( 'custom_id', $context );
364
+	public function get_custom_id($context = 'view') {
365
+        return $this->get_prop('custom_id', $context);
366 366
     }
367 367
 
368 368
     /**
@@ -372,8 +372,8 @@  discard block
 block discarded – undo
372 372
 	 * @param  string $context View or edit context.
373 373
 	 * @return string
374 374
 	 */
375
-	public function get_custom_name( $context = 'view' ) {
376
-        return $this->get_prop( 'custom_name', $context );
375
+	public function get_custom_name($context = 'view') {
376
+        return $this->get_prop('custom_name', $context);
377 377
     }
378 378
 
379 379
     /**
@@ -383,8 +383,8 @@  discard block
 block discarded – undo
383 383
 	 * @param  string $context View or edit context.
384 384
 	 * @return string
385 385
 	 */
386
-	public function get_custom_singular_name( $context = 'view' ) {
387
-        return $this->get_prop( 'custom_singular_name', $context );
386
+	public function get_custom_singular_name($context = 'view') {
387
+        return $this->get_prop('custom_singular_name', $context);
388 388
     }
389 389
 
390 390
     /**
@@ -394,8 +394,8 @@  discard block
 block discarded – undo
394 394
 	 * @param  string $context View or edit context.
395 395
 	 * @return int
396 396
 	 */
397
-	public function get_is_editable( $context = 'view' ) {
398
-        return (int) $this->get_prop( 'is_editable', $context );
397
+	public function get_is_editable($context = 'view') {
398
+        return (int) $this->get_prop('is_editable', $context);
399 399
     }
400 400
 
401 401
     /**
@@ -405,8 +405,8 @@  discard block
 block discarded – undo
405 405
 	 * @param  string $context View or edit context.
406 406
 	 * @return int
407 407
 	 */
408
-	public function get_editable( $context = 'view' ) {
409
-		return $this->get_is_editable( $context );
408
+	public function get_editable($context = 'view') {
409
+		return $this->get_is_editable($context);
410 410
     }
411 411
 
412 412
     /**
@@ -416,8 +416,8 @@  discard block
 block discarded – undo
416 416
 	 * @param  string $context View or edit context.
417 417
 	 * @return int
418 418
 	 */
419
-	public function get_is_dynamic_pricing( $context = 'view' ) {
420
-        return (int) $this->get_prop( 'is_dynamic_pricing', $context );
419
+	public function get_is_dynamic_pricing($context = 'view') {
420
+        return (int) $this->get_prop('is_dynamic_pricing', $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 float
429 429
 	 */
430
-	public function get_minimum_price( $context = 'view' ) {
431
-        return wpinv_sanitize_amount( $this->get_prop( 'minimum_price', $context ) );
430
+	public function get_minimum_price($context = 'view') {
431
+        return wpinv_sanitize_amount($this->get_prop('minimum_price', $context));
432 432
     }
433 433
 
434 434
     /**
@@ -438,8 +438,8 @@  discard block
 block discarded – undo
438 438
 	 * @param  string $context View or edit context.
439 439
 	 * @return int
440 440
 	 */
441
-	public function get_is_recurring( $context = 'view' ) {
442
-        return (int) $this->get_prop( 'is_recurring', $context );
441
+	public function get_is_recurring($context = 'view') {
442
+        return (int) $this->get_prop('is_recurring', $context);
443 443
 	}
444 444
 	
445 445
 	/**
@@ -449,9 +449,9 @@  discard block
 block discarded – undo
449 449
 	 * @param  string $context View or edit context.
450 450
 	 * @return float
451 451
 	 */
452
-	public function get_recurring_price( $context = 'view' ) {
453
-		$price = $this->get_price( $context );
454
-        return wpinv_sanitize_amount( apply_filters( 'wpinv_get_recurring_item_price', $price, $this->ID ) );
452
+	public function get_recurring_price($context = 'view') {
453
+		$price = $this->get_price($context);
454
+        return wpinv_sanitize_amount(apply_filters('wpinv_get_recurring_item_price', $price, $this->ID));
455 455
 	}
456 456
 
457 457
 	/**
@@ -472,15 +472,15 @@  discard block
 block discarded – undo
472 472
 		$period   = $this->get_recurring_period();
473 473
 		$interval = $this->get_recurring_interval();
474 474
 
475
-		if ( $this->has_free_trial() ) {
475
+		if ($this->has_free_trial()) {
476 476
 			$period   = $this->get_trial_period();
477 477
 			$interval = $this->get_trial_interval();
478 478
 		}
479 479
 
480
-		$period       = $periods[ $period ];
481
-		$interval     = empty( $interval ) ? 1 : $interval;
482
-		$next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) );
483
-        return apply_filters( 'wpinv_get_first_renewal_date', $next_renewal, $this );
480
+		$period       = $periods[$period];
481
+		$interval     = empty($interval) ? 1 : $interval;
482
+		$next_renewal = strtotime("+$interval $period", current_time('timestamp'));
483
+        return apply_filters('wpinv_get_first_renewal_date', $next_renewal, $this);
484 484
     }
485 485
 
486 486
     /**
@@ -490,14 +490,14 @@  discard block
 block discarded – undo
490 490
 	 * @param  bool $full Return abbreviation or in full.
491 491
 	 * @return string
492 492
 	 */
493
-	public function get_recurring_period( $full = false ) {
494
-        $period = $this->get_prop( 'recurring_period', 'view' );
493
+	public function get_recurring_period($full = false) {
494
+        $period = $this->get_prop('recurring_period', 'view');
495 495
 
496
-        if ( $full && ! is_bool( $full ) ) {
496
+        if ($full && !is_bool($full)) {
497 497
             $full = false;
498 498
         }
499 499
 
500
-        return getpaid_sanitize_recurring_period( $period, $full );
500
+        return getpaid_sanitize_recurring_period($period, $full);
501 501
     }
502 502
 
503 503
     /**
@@ -507,10 +507,10 @@  discard block
 block discarded – undo
507 507
 	 * @param  string $context View or edit context.
508 508
 	 * @return int
509 509
 	 */
510
-	public function get_recurring_interval( $context = 'view' ) {
511
-		$interval = absint( $this->get_prop( 'recurring_interval', $context ) );
510
+	public function get_recurring_interval($context = 'view') {
511
+		$interval = absint($this->get_prop('recurring_interval', $context));
512 512
 
513
-		if ( $interval < 1 ) {
513
+		if ($interval < 1) {
514 514
 			$interval = 1;
515 515
 		}
516 516
 
@@ -524,8 +524,8 @@  discard block
 block discarded – undo
524 524
 	 * @param  string $context View or edit context.
525 525
 	 * @return int
526 526
 	 */
527
-	public function get_recurring_limit( $context = 'view' ) {
528
-        return (int) $this->get_prop( 'recurring_limit', $context );
527
+	public function get_recurring_limit($context = 'view') {
528
+        return (int) $this->get_prop('recurring_limit', $context);
529 529
     }
530 530
 
531 531
     /**
@@ -535,8 +535,8 @@  discard block
 block discarded – undo
535 535
 	 * @param  string $context View or edit context.
536 536
 	 * @return int
537 537
 	 */
538
-	public function get_is_free_trial( $context = 'view' ) {
539
-        return (int) $this->get_prop( 'is_free_trial', $context );
538
+	public function get_is_free_trial($context = 'view') {
539
+        return (int) $this->get_prop('is_free_trial', $context);
540 540
     }
541 541
 
542 542
     /**
@@ -546,8 +546,8 @@  discard block
 block discarded – undo
546 546
 	 * @param  string $context View or edit context.
547 547
 	 * @return int
548 548
 	 */
549
-	public function get_free_trial( $context = 'view' ) {
550
-        return $this->get_is_free_trial( $context );
549
+	public function get_free_trial($context = 'view') {
550
+        return $this->get_is_free_trial($context);
551 551
     }
552 552
 
553 553
     /**
@@ -557,14 +557,14 @@  discard block
 block discarded – undo
557 557
 	 * @param  bool $full Return abbreviation or in full.
558 558
 	 * @return string
559 559
 	 */
560
-	public function get_trial_period( $full = false ) {
561
-        $period = $this->get_prop( 'trial_period', 'view' );
560
+	public function get_trial_period($full = false) {
561
+        $period = $this->get_prop('trial_period', 'view');
562 562
 
563
-        if ( $full && ! is_bool( $full ) ) {
563
+        if ($full && !is_bool($full)) {
564 564
             $full = false;
565 565
         }
566 566
 
567
-        return getpaid_sanitize_recurring_period( $period, $full );
567
+        return getpaid_sanitize_recurring_period($period, $full);
568 568
     }
569 569
 
570 570
     /**
@@ -574,8 +574,8 @@  discard block
 block discarded – undo
574 574
 	 * @param  string $context View or edit context.
575 575
 	 * @return int
576 576
 	 */
577
-	public function get_trial_interval( $context = 'view' ) {
578
-        return (int) $this->get_prop( 'trial_interval', $context );
577
+	public function get_trial_interval($context = 'view') {
578
+        return (int) $this->get_prop('trial_interval', $context);
579 579
 	}
580 580
 	
581 581
 	/**
@@ -585,25 +585,25 @@  discard block
 block discarded – undo
585 585
 	 * @return string
586 586
 	 */
587 587
 	public function get_edit_url() {
588
-        return get_edit_post_link( $this->get_id() );
588
+        return get_edit_post_link($this->get_id());
589 589
 	}
590 590
 
591 591
     /**
592 592
      * Margic method for retrieving a property.
593 593
      */
594
-    public function __get( $key ) {
594
+    public function __get($key) {
595 595
 
596 596
         // Check if we have a helper method for that.
597
-        if ( method_exists( $this, 'get_' . $key ) ) {
598
-            return call_user_func( array( $this, 'get_' . $key ) );
597
+        if (method_exists($this, 'get_' . $key)) {
598
+            return call_user_func(array($this, 'get_' . $key));
599 599
         }
600 600
 
601 601
         // Check if the key is in the associated $post object.
602
-        if ( ! empty( $this->post ) && isset( $this->post->$key ) ) {
602
+        if (!empty($this->post) && isset($this->post->$key)) {
603 603
             return $this->post->$key;
604 604
         }
605 605
 
606
-        return $this->get_prop( $key );
606
+        return $this->get_prop($key);
607 607
 
608 608
     }
609 609
 
@@ -622,11 +622,11 @@  discard block
 block discarded – undo
622 622
 	 *
623 623
 	 * @since 1.0.19
624 624
 	 */
625
-	public function set_parent_id( $value ) {
626
-		if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) {
625
+	public function set_parent_id($value) {
626
+		if ($value && ($value === $this->get_id() || !get_post($value))) {
627 627
 			return;
628 628
 		}
629
-		$this->set_prop( 'parent_id', absint( $value ) );
629
+		$this->set_prop('parent_id', absint($value));
630 630
 	}
631 631
 
632 632
     /**
@@ -636,10 +636,10 @@  discard block
 block discarded – undo
636 636
 	 * @param  string $status New status.
637 637
 	 * @return array details of change.
638 638
 	 */
639
-	public function set_status( $status ) {
639
+	public function set_status($status) {
640 640
         $old_status = $this->get_status();
641 641
 
642
-        $this->set_prop( 'status', $status );
642
+        $this->set_prop('status', $status);
643 643
 
644 644
 		return array(
645 645
 			'from' => $old_status,
@@ -652,8 +652,8 @@  discard block
 block discarded – undo
652 652
 	 *
653 653
 	 * @since 1.0.19
654 654
 	 */
655
-	public function set_version( $value ) {
656
-		$this->set_prop( 'version', $value );
655
+	public function set_version($value) {
656
+		$this->set_prop('version', $value);
657 657
     }
658 658
 
659 659
     /**
@@ -663,11 +663,11 @@  discard block
 block discarded – undo
663 663
 	 * @param string $value Value to set.
664 664
      * @return bool Whether or not the date was set.
665 665
 	 */
666
-	public function set_date_created( $value ) {
667
-        $date = strtotime( $value );
666
+	public function set_date_created($value) {
667
+        $date = strtotime($value);
668 668
 
669
-        if ( $date ) {
670
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
669
+        if ($date) {
670
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
671 671
             return true;
672 672
         }
673 673
 
@@ -682,11 +682,11 @@  discard block
 block discarded – undo
682 682
 	 * @param string $value Value to set.
683 683
      * @return bool Whether or not the date was set.
684 684
 	 */
685
-	public function set_date_modified( $value ) {
686
-        $date = strtotime( $value );
685
+	public function set_date_modified($value) {
686
+        $date = strtotime($value);
687 687
 
688
-        if ( $date ) {
689
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
688
+        if ($date) {
689
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
690 690
             return true;
691 691
         }
692 692
 
@@ -700,9 +700,9 @@  discard block
 block discarded – undo
700 700
 	 * @since 1.0.19
701 701
 	 * @param  string $value New name.
702 702
 	 */
703
-	public function set_name( $value ) {
704
-        $name = sanitize_text_field( $value );
705
-		$this->set_prop( 'name', $name );
703
+	public function set_name($value) {
704
+        $name = sanitize_text_field($value);
705
+		$this->set_prop('name', $name);
706 706
     }
707 707
 
708 708
     /**
@@ -711,8 +711,8 @@  discard block
 block discarded – undo
711 711
 	 * @since 1.0.19
712 712
 	 * @param  string $value New name.
713 713
 	 */
714
-	public function set_title( $value ) {
715
-		$this->set_name( $value );
714
+	public function set_title($value) {
715
+		$this->set_name($value);
716 716
     }
717 717
 
718 718
     /**
@@ -721,9 +721,9 @@  discard block
 block discarded – undo
721 721
 	 * @since 1.0.19
722 722
 	 * @param  string $value New description.
723 723
 	 */
724
-	public function set_description( $value ) {
725
-        $description = wp_kses_post( $value );
726
-		return $this->set_prop( 'description', $description );
724
+	public function set_description($value) {
725
+        $description = wp_kses_post($value);
726
+		return $this->set_prop('description', $description);
727 727
     }
728 728
 
729 729
     /**
@@ -732,8 +732,8 @@  discard block
 block discarded – undo
732 732
 	 * @since 1.0.19
733 733
 	 * @param  string $value New description.
734 734
 	 */
735
-	public function set_excerpt( $value ) {
736
-		$this->set_description( $value );
735
+	public function set_excerpt($value) {
736
+		$this->set_description($value);
737 737
     }
738 738
 
739 739
     /**
@@ -742,8 +742,8 @@  discard block
 block discarded – undo
742 742
 	 * @since 1.0.19
743 743
 	 * @param  string $value New description.
744 744
 	 */
745
-	public function set_summary( $value ) {
746
-		$this->set_description( $value );
745
+	public function set_summary($value) {
746
+		$this->set_description($value);
747 747
     }
748 748
 
749 749
     /**
@@ -752,8 +752,8 @@  discard block
 block discarded – undo
752 752
 	 * @since 1.0.19
753 753
 	 * @param  int $value New author.
754 754
 	 */
755
-	public function set_author( $value ) {
756
-		$this->set_prop( 'author', (int) $value );
755
+	public function set_author($value) {
756
+		$this->set_prop('author', (int) $value);
757 757
     }
758 758
 
759 759
     /**
@@ -762,8 +762,8 @@  discard block
 block discarded – undo
762 762
 	 * @since 1.0.19
763 763
 	 * @param  float $value New price.
764 764
 	 */
765
-	public function set_price( $value ) {
766
-        $this->set_prop( 'price', (float) wpinv_sanitize_amount( $value ) );
765
+	public function set_price($value) {
766
+        $this->set_prop('price', (float) wpinv_sanitize_amount($value));
767 767
     }
768 768
 
769 769
     /**
@@ -772,8 +772,8 @@  discard block
 block discarded – undo
772 772
 	 * @since 1.0.19
773 773
 	 * @param  string $value new rule.
774 774
 	 */
775
-	public function set_vat_rule( $value ) {
776
-        $this->set_prop( 'vat_rule', $value );
775
+	public function set_vat_rule($value) {
776
+        $this->set_prop('vat_rule', $value);
777 777
     }
778 778
 
779 779
     /**
@@ -782,8 +782,8 @@  discard block
 block discarded – undo
782 782
 	 * @since 1.0.19
783 783
 	 * @param  string $value new class.
784 784
 	 */
785
-	public function set_vat_class( $value ) {
786
-        $this->set_prop( 'vat_class', $value );
785
+	public function set_vat_class($value) {
786
+        $this->set_prop('vat_class', $value);
787 787
     }
788 788
 
789 789
     /**
@@ -793,13 +793,13 @@  discard block
 block discarded – undo
793 793
 	 * @param  string $value new item type.
794 794
 	 * @return string
795 795
 	 */
796
-	public function set_type( $value ) {
796
+	public function set_type($value) {
797 797
 
798
-        if ( empty( $value ) ) {
798
+        if (empty($value)) {
799 799
             $value = 'custom';
800 800
         }
801 801
 
802
-        $this->set_prop( 'type', $value );
802
+        $this->set_prop('type', $value);
803 803
     }
804 804
 
805 805
     /**
@@ -808,8 +808,8 @@  discard block
 block discarded – undo
808 808
 	 * @since 1.0.19
809 809
 	 * @param  string $value new custom id.
810 810
 	 */
811
-	public function set_custom_id( $value ) {
812
-        $this->set_prop( 'custom_id', $value );
811
+	public function set_custom_id($value) {
812
+        $this->set_prop('custom_id', $value);
813 813
     }
814 814
 
815 815
     /**
@@ -818,8 +818,8 @@  discard block
 block discarded – undo
818 818
 	 * @since 1.0.19
819 819
 	 * @param  string $value new custom name.
820 820
 	 */
821
-	public function set_custom_name( $value ) {
822
-        $this->set_prop( 'custom_name', $value );
821
+	public function set_custom_name($value) {
822
+        $this->set_prop('custom_name', $value);
823 823
     }
824 824
 
825 825
     /**
@@ -828,8 +828,8 @@  discard block
 block discarded – undo
828 828
 	 * @since 1.0.19
829 829
 	 * @param  string $value new custom singular name.
830 830
 	 */
831
-	public function set_custom_singular_name( $value ) {
832
-        $this->set_prop( 'custom_singular_name', $value );
831
+	public function set_custom_singular_name($value) {
832
+        $this->set_prop('custom_singular_name', $value);
833 833
     }
834 834
 
835 835
     /**
@@ -838,9 +838,9 @@  discard block
 block discarded – undo
838 838
 	 * @since 1.0.19
839 839
 	 * @param  int|bool $value whether or not the item is editable.
840 840
 	 */
841
-	public function set_is_editable( $value ) {
842
-		if ( is_numeric( $value ) ) {
843
-			$this->set_prop( 'is_editable', (int) $value );
841
+	public function set_is_editable($value) {
842
+		if (is_numeric($value)) {
843
+			$this->set_prop('is_editable', (int) $value);
844 844
 		}
845 845
     }
846 846
 
@@ -850,8 +850,8 @@  discard block
 block discarded – undo
850 850
 	 * @since 1.0.19
851 851
 	 * @param  int|bool $value whether or not dynamic pricing is allowed.
852 852
 	 */
853
-	public function set_is_dynamic_pricing( $value ) {
854
-        $this->set_prop( 'is_dynamic_pricing', (int) $value );
853
+	public function set_is_dynamic_pricing($value) {
854
+        $this->set_prop('is_dynamic_pricing', (int) $value);
855 855
     }
856 856
 
857 857
     /**
@@ -860,8 +860,8 @@  discard block
 block discarded – undo
860 860
 	 * @since 1.0.19
861 861
 	 * @param  float $value minimum price.
862 862
 	 */
863
-	public function set_minimum_price( $value ) {
864
-        $this->set_prop( 'minimum_price',  (float) wpinv_sanitize_amount( $value ) );
863
+	public function set_minimum_price($value) {
864
+        $this->set_prop('minimum_price', (float) wpinv_sanitize_amount($value));
865 865
     }
866 866
 
867 867
     /**
@@ -870,8 +870,8 @@  discard block
 block discarded – undo
870 870
 	 * @since 1.0.19
871 871
 	 * @param  int|bool $value whether or not dynamic pricing is allowed.
872 872
 	 */
873
-	public function set_is_recurring( $value ) {
874
-        $this->set_prop( 'is_recurring', (int) $value );
873
+	public function set_is_recurring($value) {
874
+        $this->set_prop('is_recurring', (int) $value);
875 875
     }
876 876
 
877 877
     /**
@@ -880,8 +880,8 @@  discard block
 block discarded – undo
880 880
 	 * @since 1.0.19
881 881
 	 * @param  string $value new period.
882 882
 	 */
883
-	public function set_recurring_period( $value ) {
884
-        $this->set_prop( 'recurring_period', $value );
883
+	public function set_recurring_period($value) {
884
+        $this->set_prop('recurring_period', $value);
885 885
     }
886 886
 
887 887
     /**
@@ -890,8 +890,8 @@  discard block
 block discarded – undo
890 890
 	 * @since 1.0.19
891 891
 	 * @param  int $value recurring interval.
892 892
 	 */
893
-	public function set_recurring_interval( $value ) {
894
-        return $this->set_prop( 'recurring_interval', (int) $value );
893
+	public function set_recurring_interval($value) {
894
+        return $this->set_prop('recurring_interval', (int) $value);
895 895
     }
896 896
 
897 897
     /**
@@ -900,8 +900,8 @@  discard block
 block discarded – undo
900 900
 	 * @param  int $value The recurring limit.
901 901
 	 * @return int
902 902
 	 */
903
-	public function set_recurring_limit( $value ) {
904
-        $this->set_prop( 'recurring_limit', (int) $value );
903
+	public function set_recurring_limit($value) {
904
+        $this->set_prop('recurring_limit', (int) $value);
905 905
     }
906 906
 
907 907
     /**
@@ -910,8 +910,8 @@  discard block
 block discarded – undo
910 910
 	 * @since 1.0.19
911 911
 	 * @param  int|bool $value whether or not it has a free trial.
912 912
 	 */
913
-	public function set_is_free_trial( $value ) {
914
-        $this->set_prop( 'is_free_trial', (int) $value );
913
+	public function set_is_free_trial($value) {
914
+        $this->set_prop('is_free_trial', (int) $value);
915 915
     }
916 916
 
917 917
     /**
@@ -920,8 +920,8 @@  discard block
 block discarded – undo
920 920
 	 * @since 1.0.19
921 921
 	 * @param  string $value trial period.
922 922
 	 */
923
-	public function set_trial_period( $value ) {
924
-        $this->set_prop( 'trial_period', $value );
923
+	public function set_trial_period($value) {
924
+        $this->set_prop('trial_period', $value);
925 925
     }
926 926
 
927 927
     /**
@@ -930,8 +930,8 @@  discard block
 block discarded – undo
930 930
 	 * @since 1.0.19
931 931
 	 * @param  int $value trial interval.
932 932
 	 */
933
-	public function set_trial_interval( $value ) {
934
-        $this->set_prop( 'trial_interval', $value );
933
+	public function set_trial_interval($value) {
934
+        $this->set_prop('trial_interval', $value);
935 935
     }
936 936
 
937 937
     /**
@@ -940,11 +940,11 @@  discard block
 block discarded – undo
940 940
      * @deprecated
941 941
 	 * @return int item id
942 942
      */
943
-    public function create( $data = array() ) {
943
+    public function create($data = array()) {
944 944
 
945 945
 		// Set the properties.
946
-		if ( is_array( $data ) ) {
947
-			$this->set_props( $data );
946
+		if (is_array($data)) {
947
+			$this->set_props($data);
948 948
 		}
949 949
 
950 950
 		// Save the item.
@@ -958,8 +958,8 @@  discard block
 block discarded – undo
958 958
      * @deprecated
959 959
 	 * @return int item id
960 960
      */
961
-    public function update( $data = array() ) {
962
-        return $this->create( $data );
961
+    public function update($data = array()) {
962
+        return $this->create($data);
963 963
     }
964 964
 
965 965
     /*
@@ -999,7 +999,7 @@  discard block
 block discarded – undo
999 999
 	 */
1000 1000
     public function has_free_trial() {
1001 1001
         $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false;
1002
-        return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this );
1002
+        return (bool) apply_filters('wpinv_item_has_free_trial', $has_trial, $this->ID, $this);
1003 1003
     }
1004 1004
 
1005 1005
     /**
@@ -1009,8 +1009,8 @@  discard block
 block discarded – undo
1009 1009
 	 * @return bool
1010 1010
 	 */
1011 1011
     public function is_free() {
1012
-        $is_free   = $this->get_price() == 0;
1013
-        return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this );
1012
+        $is_free = $this->get_price() == 0;
1013
+        return (bool) apply_filters('wpinv_is_free_item', $is_free, $this->ID, $this);
1014 1014
     }
1015 1015
 
1016 1016
     /**
@@ -1019,9 +1019,9 @@  discard block
 block discarded – undo
1019 1019
 	 * @param array|string $status Status to check.
1020 1020
 	 * @return bool
1021 1021
 	 */
1022
-	public function has_status( $status ) {
1023
-		$has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status;
1024
-		return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status );
1022
+	public function has_status($status) {
1023
+		$has_status = (is_array($status) && in_array($this->get_status(), $status, true)) || $this->get_status() === $status;
1024
+		return (bool) apply_filters('getpaid_item_has_status', $has_status, $this, $status);
1025 1025
     }
1026 1026
 
1027 1027
     /**
@@ -1030,9 +1030,9 @@  discard block
 block discarded – undo
1030 1030
 	 * @param array|string $type Type to check.
1031 1031
 	 * @return bool
1032 1032
 	 */
1033
-	public function is_type( $type ) {
1034
-		$is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type;
1035
-		return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type );
1033
+	public function is_type($type) {
1034
+		$is_type = (is_array($type) && in_array($this->get_type(), $type, true)) || $this->get_type() === $type;
1035
+		return (bool) apply_filters('getpaid_item_is_type', $is_type, $this, $type);
1036 1036
 	}
1037 1037
 
1038 1038
     /**
@@ -1043,53 +1043,53 @@  discard block
 block discarded – undo
1043 1043
 	 */
1044 1044
     public function is_editable() {
1045 1045
         $is_editable = $this->get_is_editable();
1046
-        return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this );
1046
+        return (bool) apply_filters('wpinv_item_is_editable', $is_editable, $this->ID, $this);
1047 1047
 	}
1048 1048
 
1049 1049
 	/**
1050 1050
 	 * Returns an array of cart fees.
1051 1051
 	 */
1052
-	public function get_fees( $type = 'fee', $item_id = 0 ) {
1052
+	public function get_fees($type = 'fee', $item_id = 0) {
1053 1053
         global $wpi_session;
1054 1054
         
1055
-        $fees = $wpi_session->get( 'wpi_cart_fees' );
1055
+        $fees = $wpi_session->get('wpi_cart_fees');
1056 1056
 
1057
-        if ( ! wpinv_get_cart_contents() ) {
1057
+        if (!wpinv_get_cart_contents()) {
1058 1058
             // We can only get item type fees when the cart is empty
1059 1059
             $type = 'custom';
1060 1060
         }
1061 1061
 
1062
-        if ( ! empty( $fees ) && ! empty( $type ) && 'all' !== $type ) {
1063
-            foreach( $fees as $key => $fee ) {
1064
-                if( ! empty( $fee['type'] ) && $type != $fee['type'] ) {
1065
-                    unset( $fees[ $key ] );
1062
+        if (!empty($fees) && !empty($type) && 'all' !== $type) {
1063
+            foreach ($fees as $key => $fee) {
1064
+                if (!empty($fee['type']) && $type != $fee['type']) {
1065
+                    unset($fees[$key]);
1066 1066
                 }
1067 1067
             }
1068 1068
         }
1069 1069
 
1070
-        if ( ! empty( $fees ) && ! empty( $item_id ) ) {
1070
+        if (!empty($fees) && !empty($item_id)) {
1071 1071
             // Remove fees that don't belong to the specified Item
1072
-            foreach ( $fees as $key => $fee ) {
1073
-                if ( (int) $item_id !== (int)$fee['custom_id'] ) {
1074
-                    unset( $fees[ $key ] );
1072
+            foreach ($fees as $key => $fee) {
1073
+                if ((int) $item_id !== (int) $fee['custom_id']) {
1074
+                    unset($fees[$key]);
1075 1075
                 }
1076 1076
             }
1077 1077
         }
1078 1078
 
1079
-        if ( ! empty( $fees ) ) {
1079
+        if (!empty($fees)) {
1080 1080
             // Remove fees that belong to a specific item but are not in the cart
1081
-            foreach( $fees as $key => $fee ) {
1082
-                if( empty( $fee['custom_id'] ) ) {
1081
+            foreach ($fees as $key => $fee) {
1082
+                if (empty($fee['custom_id'])) {
1083 1083
                     continue;
1084 1084
                 }
1085 1085
 
1086
-                if ( !wpinv_item_in_cart( $fee['custom_id'] ) ) {
1087
-                    unset( $fees[ $key ] );
1086
+                if (!wpinv_item_in_cart($fee['custom_id'])) {
1087
+                    unset($fees[$key]);
1088 1088
                 }
1089 1089
             }
1090 1090
         }
1091 1091
 
1092
-        return ! empty( $fees ) ? $fees : array();
1092
+        return !empty($fees) ? $fees : array();
1093 1093
     }
1094 1094
 
1095 1095
     /**
@@ -1101,11 +1101,11 @@  discard block
 block discarded – undo
1101 1101
     public function can_purchase() {
1102 1102
         $can_purchase = null !== $this->get_id();
1103 1103
 
1104
-        if ( ! current_user_can( 'edit_post', $this->ID ) && $this->post_status != 'publish' ) {
1104
+        if (!current_user_can('edit_post', $this->ID) && $this->post_status != 'publish') {
1105 1105
             $can_purchase = false;
1106 1106
         }
1107 1107
 
1108
-        return (bool) apply_filters( 'wpinv_can_purchase_item', $can_purchase, $this );
1108
+        return (bool) apply_filters('wpinv_can_purchase_item', $can_purchase, $this);
1109 1109
     }
1110 1110
 
1111 1111
     /**
@@ -1115,6 +1115,6 @@  discard block
 block discarded – undo
1115 1115
 	 * @return bool
1116 1116
 	 */
1117 1117
     public function supports_dynamic_pricing() {
1118
-        return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this );
1118
+        return (bool) apply_filters('wpinv_item_supports_dynamic_pricing', true, $this);
1119 1119
     }
1120 1120
 }
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-paypal-gateway.php 2 patches
Indentation   +331 added lines, -331 removed lines patch added patch discarded remove patch
@@ -13,72 +13,72 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Paypal_Gateway extends GetPaid_Payment_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'paypal';
21 21
 
22 22
     /**
23
-	 * An array of features that this gateway supports.
24
-	 *
25
-	 * @var array
26
-	 */
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27 27
     protected $supports = array( 'subscription', 'sandbox' );
28 28
 
29 29
     /**
30
-	 * Payment method order.
31
-	 *
32
-	 * @var int
33
-	 */
30
+     * Payment method order.
31
+     *
32
+     * @var int
33
+     */
34 34
     public $order = 1;
35 35
 
36 36
     /**
37
-	 * Stores line items to send to PayPal.
38
-	 *
39
-	 * @var array
40
-	 */
37
+     * Stores line items to send to PayPal.
38
+     *
39
+     * @var array
40
+     */
41 41
     protected $line_items = array();
42 42
 
43 43
     /**
44
-	 * Endpoint for requests from PayPal.
45
-	 *
46
-	 * @var string
47
-	 */
48
-	protected $notify_url;
44
+     * Endpoint for requests from PayPal.
45
+     *
46
+     * @var string
47
+     */
48
+    protected $notify_url;
49 49
 
50
-	/**
51
-	 * Endpoint for requests to PayPal.
52
-	 *
53
-	 * @var string
54
-	 */
50
+    /**
51
+     * Endpoint for requests to PayPal.
52
+     *
53
+     * @var string
54
+     */
55 55
     protected $endpoint;
56 56
     
57 57
     /**
58
-	 * Currencies this gateway is allowed for.
59
-	 *
60
-	 * @var array
61
-	 */
62
-	public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' );
58
+     * Currencies this gateway is allowed for.
59
+     *
60
+     * @var array
61
+     */
62
+    public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' );
63 63
 
64 64
     /**
65
-	 * URL to view a transaction.
66
-	 *
67
-	 * @var string
68
-	 */
65
+     * URL to view a transaction.
66
+     *
67
+     * @var string
68
+     */
69 69
     public $view_transaction_url = 'https://www.{sandbox}paypal.com/activity/payment/%s';
70 70
 
71 71
     /**
72
-	 * URL to view a subscription.
73
-	 *
74
-	 * @var string
75
-	 */
76
-	public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s';
72
+     * URL to view a subscription.
73
+     *
74
+     * @var string
75
+     */
76
+    public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s';
77 77
 
78 78
     /**
79
-	 * Class constructor.
80
-	 */
81
-	public function __construct() {
79
+     * Class constructor.
80
+     */
81
+    public function __construct() {
82 82
 
83 83
         $this->title             = __( 'PayPal Standard', 'invoicing' );
84 84
         $this->method_title      = __( 'PayPal Standard', 'invoicing' );
@@ -92,15 +92,15 @@  discard block
 block discarded – undo
92 92
     }
93 93
 
94 94
     /**
95
-	 * Process Payment.
96
-	 *
97
-	 *
98
-	 * @param WPInv_Invoice $invoice Invoice.
99
-	 * @param array $submission_data Posted checkout fields.
100
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
101
-	 * @return array
102
-	 */
103
-	public function process_payment( $invoice, $submission_data, $submission ) {
95
+     * Process Payment.
96
+     *
97
+     *
98
+     * @param WPInv_Invoice $invoice Invoice.
99
+     * @param array $submission_data Posted checkout fields.
100
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
101
+     * @return array
102
+     */
103
+    public function process_payment( $invoice, $submission_data, $submission ) {
104 104
 
105 105
         // Get redirect url.
106 106
         $paypal_redirect = $this->get_request_url( $invoice );
@@ -123,15 +123,15 @@  discard block
 block discarded – undo
123 123
     }
124 124
 
125 125
     /**
126
-	 * Get the PayPal request URL for an invoice.
127
-	 *
128
-	 * @param  WPInv_Invoice $invoice Invoice object.
129
-	 * @return string
130
-	 */
131
-	public function get_request_url( $invoice ) {
126
+     * Get the PayPal request URL for an invoice.
127
+     *
128
+     * @param  WPInv_Invoice $invoice Invoice object.
129
+     * @return string
130
+     */
131
+    public function get_request_url( $invoice ) {
132 132
 
133 133
         // Endpoint for this request
134
-		$this->endpoint    = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
134
+        $this->endpoint    = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
135 135
 
136 136
         // Retrieve paypal args.
137 137
         $paypal_args       = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' );
@@ -144,44 +144,44 @@  discard block
 block discarded – undo
144 144
 
145 145
         return add_query_arg( $paypal_args, $this->endpoint );
146 146
 
147
-	}
147
+    }
148 148
 
149 149
     /**
150
-	 * Get PayPal Args for passing to PP.
151
-	 *
152
-	 * @param  WPInv_Invoice $invoice Invoice object.
153
-	 * @return array
154
-	 */
155
-	protected function get_paypal_args( $invoice ) {
150
+     * Get PayPal Args for passing to PP.
151
+     *
152
+     * @param  WPInv_Invoice $invoice Invoice object.
153
+     * @return array
154
+     */
155
+    protected function get_paypal_args( $invoice ) {
156 156
 
157 157
         // Whether or not to send the line items as one item.
158
-		$force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', false, $invoice );
159
-
160
-		if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) {
161
-			$force_one_line_item = true;
162
-		}
163
-
164
-		$paypal_args = apply_filters(
165
-			'getpaid_paypal_args',
166
-			array_merge(
167
-				$this->get_transaction_args( $invoice ),
168
-				$this->get_line_item_args( $invoice, $force_one_line_item )
169
-			),
170
-			$invoice
171
-		);
172
-
173
-		return $this->fix_request_length( $invoice, $paypal_args );
158
+        $force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', false, $invoice );
159
+
160
+        if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) {
161
+            $force_one_line_item = true;
162
+        }
163
+
164
+        $paypal_args = apply_filters(
165
+            'getpaid_paypal_args',
166
+            array_merge(
167
+                $this->get_transaction_args( $invoice ),
168
+                $this->get_line_item_args( $invoice, $force_one_line_item )
169
+            ),
170
+            $invoice
171
+        );
172
+
173
+        return $this->fix_request_length( $invoice, $paypal_args );
174 174
     }
175 175
 
176 176
     /**
177
-	 * Get transaction args for paypal request.
178
-	 *
179
-	 * @param WPInv_Invoice $invoice Invoice object.
180
-	 * @return array
181
-	 */
182
-	protected function get_transaction_args( $invoice ) {
177
+     * Get transaction args for paypal request.
178
+     *
179
+     * @param WPInv_Invoice $invoice Invoice object.
180
+     * @return array
181
+     */
182
+    protected function get_transaction_args( $invoice ) {
183 183
 
184
-		return array(
184
+        return array(
185 185
             'cmd'           => '_cart',
186 186
             'business'      => wpinv_get_option( 'paypal_email', false ),
187 187
             'no_shipping'   => '1',
@@ -206,16 +206,16 @@  discard block
 block discarded – undo
206 206
     }
207 207
 
208 208
     /**
209
-	 * Get line item args for paypal request.
210
-	 *
211
-	 * @param  WPInv_Invoice $invoice Invoice object.
212
-	 * @param  bool     $force_one_line_item Create only one item for this invoice.
213
-	 * @return array
214
-	 */
215
-	protected function get_line_item_args( $invoice, $force_one_line_item = false ) {
209
+     * Get line item args for paypal request.
210
+     *
211
+     * @param  WPInv_Invoice $invoice Invoice object.
212
+     * @param  bool     $force_one_line_item Create only one item for this invoice.
213
+     * @return array
214
+     */
215
+    protected function get_line_item_args( $invoice, $force_one_line_item = false ) {
216 216
 
217 217
         // Maybe send invoice as a single item.
218
-		if ( $force_one_line_item ) {
218
+        if ( $force_one_line_item ) {
219 219
             return $this->get_line_item_args_single_item( $invoice );
220 220
         }
221 221
 
@@ -235,129 +235,129 @@  discard block
 block discarded – undo
235 235
             $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 );
236 236
         }
237 237
 
238
-		return array_merge( $line_item_args, $this->get_line_items() );
238
+        return array_merge( $line_item_args, $this->get_line_items() );
239 239
 
240 240
     }
241 241
 
242 242
     /**
243
-	 * Get line item args for paypal request as a single line item.
244
-	 *
245
-	 * @param  WPInv_Invoice $invoice Invoice object.
246
-	 * @return array
247
-	 */
248
-	protected function get_line_item_args_single_item( $invoice ) {
249
-		$this->delete_line_items();
243
+     * Get line item args for paypal request as a single line item.
244
+     *
245
+     * @param  WPInv_Invoice $invoice Invoice object.
246
+     * @return array
247
+     */
248
+    protected function get_line_item_args_single_item( $invoice ) {
249
+        $this->delete_line_items();
250 250
 
251 251
         $item_name = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() );
252
-		$this->add_line_item( $item_name, 1, wpinv_sanitize_amount( (float) $invoice->get_total(), 2 ), $invoice->get_id() );
252
+        $this->add_line_item( $item_name, 1, wpinv_sanitize_amount( (float) $invoice->get_total(), 2 ), $invoice->get_id() );
253 253
 
254
-		return $this->get_line_items();
254
+        return $this->get_line_items();
255 255
     }
256 256
 
257 257
     /**
258
-	 * Return all line items.
259
-	 */
260
-	protected function get_line_items() {
261
-		return $this->line_items;
262
-	}
258
+     * Return all line items.
259
+     */
260
+    protected function get_line_items() {
261
+        return $this->line_items;
262
+    }
263 263
 
264 264
     /**
265
-	 * Remove all line items.
266
-	 */
267
-	protected function delete_line_items() {
268
-		$this->line_items = array();
265
+     * Remove all line items.
266
+     */
267
+    protected function delete_line_items() {
268
+        $this->line_items = array();
269 269
     }
270 270
 
271 271
     /**
272
-	 * Prepare line items to send to paypal.
273
-	 *
274
-	 * @param  WPInv_Invoice $invoice Invoice object.
275
-	 */
276
-	protected function prepare_line_items( $invoice ) {
277
-		$this->delete_line_items();
278
-
279
-		// Items.
280
-		foreach ( $invoice->get_items() as $item ) {
281
-			$amount   = $invoice->get_template() == 'amount' ? $item->get_price() : $item->get_sub_total();
282
-			$quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity();
283
-			$this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() );
272
+     * Prepare line items to send to paypal.
273
+     *
274
+     * @param  WPInv_Invoice $invoice Invoice object.
275
+     */
276
+    protected function prepare_line_items( $invoice ) {
277
+        $this->delete_line_items();
278
+
279
+        // Items.
280
+        foreach ( $invoice->get_items() as $item ) {
281
+            $amount   = $invoice->get_template() == 'amount' ? $item->get_price() : $item->get_sub_total();
282
+            $quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity();
283
+            $this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() );
284 284
         }
285 285
 
286 286
         // Fees.
287
-		foreach ( $invoice->get_fees() as $fee => $data ) {
287
+        foreach ( $invoice->get_fees() as $fee => $data ) {
288 288
             $this->add_line_item( $fee, 1, $data['amount'] );
289 289
         }
290 290
 
291 291
     }
292 292
 
293 293
     /**
294
-	 * Add PayPal Line Item.
295
-	 *
296
-	 * @param  string $item_name Item name.
297
-	 * @param  int    $quantity Item quantity.
298
-	 * @param  float  $amount Amount.
299
-	 * @param  string $item_number Item number.
300
-	 */
301
-	protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) {
302
-		$index = ( count( $this->line_items ) / 4 ) + 1;
303
-
304
-		$item = apply_filters(
305
-			'getpaid_paypal_line_item',
306
-			array(
307
-				'item_name'   => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
308
-				'quantity'    => (int) $quantity,
309
-				'amount'      => wpinv_sanitize_amount( (float) $amount, 2 ),
310
-				'item_number' => $item_number,
311
-			),
312
-			$item_name,
313
-			$quantity,
314
-			$amount,
315
-			$item_number
316
-		);
317
-
318
-		$this->line_items[ 'item_name_' . $index ]   = getpaid_limit_length( $item['item_name'], 127 );
294
+     * Add PayPal Line Item.
295
+     *
296
+     * @param  string $item_name Item name.
297
+     * @param  int    $quantity Item quantity.
298
+     * @param  float  $amount Amount.
299
+     * @param  string $item_number Item number.
300
+     */
301
+    protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) {
302
+        $index = ( count( $this->line_items ) / 4 ) + 1;
303
+
304
+        $item = apply_filters(
305
+            'getpaid_paypal_line_item',
306
+            array(
307
+                'item_name'   => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
308
+                'quantity'    => (int) $quantity,
309
+                'amount'      => wpinv_sanitize_amount( (float) $amount, 2 ),
310
+                'item_number' => $item_number,
311
+            ),
312
+            $item_name,
313
+            $quantity,
314
+            $amount,
315
+            $item_number
316
+        );
317
+
318
+        $this->line_items[ 'item_name_' . $index ]   = getpaid_limit_length( $item['item_name'], 127 );
319 319
         $this->line_items[ 'quantity_' . $index ]    = $item['quantity'];
320 320
         
321 321
         // The price or amount of the product, service, or contribution, not including shipping, handling, or tax.
322
-		$this->line_items[ 'amount_' . $index ]      = $item['amount'];
323
-		$this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 );
322
+        $this->line_items[ 'amount_' . $index ]      = $item['amount'];
323
+        $this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 );
324 324
     }
325 325
 
326 326
     /**
327
-	 * If the default request with line items is too long, generate a new one with only one line item.
328
-	 *
329
-	 * https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer.
330
-	 *
331
-	 * @param WPInv_Invoice $invoice Invoice to be sent to Paypal.
332
-	 * @param array    $paypal_args Arguments sent to Paypal in the request.
333
-	 * @return array
334
-	 */
335
-	protected function fix_request_length( $invoice, $paypal_args ) {
336
-		$max_paypal_length = 2083;
337
-		$query_candidate   = http_build_query( $paypal_args, '', '&' );
338
-
339
-		if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) {
340
-			return $paypal_args;
341
-		}
342
-
343
-		return apply_filters(
344
-			'getpaid_paypal_args',
345
-			array_merge(
346
-				$this->get_transaction_args( $invoice ),
347
-				$this->get_line_item_args( $invoice, true )
348
-			),
349
-			$invoice
350
-		);
327
+     * If the default request with line items is too long, generate a new one with only one line item.
328
+     *
329
+     * https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer.
330
+     *
331
+     * @param WPInv_Invoice $invoice Invoice to be sent to Paypal.
332
+     * @param array    $paypal_args Arguments sent to Paypal in the request.
333
+     * @return array
334
+     */
335
+    protected function fix_request_length( $invoice, $paypal_args ) {
336
+        $max_paypal_length = 2083;
337
+        $query_candidate   = http_build_query( $paypal_args, '', '&' );
338
+
339
+        if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) {
340
+            return $paypal_args;
341
+        }
342
+
343
+        return apply_filters(
344
+            'getpaid_paypal_args',
345
+            array_merge(
346
+                $this->get_transaction_args( $invoice ),
347
+                $this->get_line_item_args( $invoice, true )
348
+            ),
349
+            $invoice
350
+        );
351 351
 
352 352
     }
353 353
     
354 354
     /**
355
-	 * Processes recurring invoices.
356
-	 *
357
-	 * @param  array $paypal_args PayPal args.
358
-	 * @param  WPInv_Invoice    $invoice Invoice object.
359
-	 */
360
-	public function process_subscription( $paypal_args, $invoice ) {
355
+     * Processes recurring invoices.
356
+     *
357
+     * @param  array $paypal_args PayPal args.
358
+     * @param  WPInv_Invoice    $invoice Invoice object.
359
+     */
360
+    public function process_subscription( $paypal_args, $invoice ) {
361 361
 
362 362
         // Make sure this is a subscription.
363 363
         if ( ! $invoice->is_recurring() || ! $subscription = wpinv_get_subscription( $invoice ) ) {
@@ -382,11 +382,11 @@  discard block
 block discarded – undo
382 382
 
383 383
             $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount;
384 384
 
385
-			// Trial period length.
386
-			$paypal_args['p1'] = $subscription_item->get_trial_interval();
385
+            // Trial period length.
386
+            $paypal_args['p1'] = $subscription_item->get_trial_interval();
387 387
 
388
-			// Trial period.
389
-			$paypal_args['t1'] = $subscription_item->get_trial_period();
388
+            // Trial period.
389
+            $paypal_args['t1'] = $subscription_item->get_trial_period();
390 390
 
391 391
         } else if ( $initial_amount != $recurring_amount ) {
392 392
 
@@ -409,40 +409,40 @@  discard block
 block discarded – undo
409 409
         }
410 410
 
411 411
         // We have a recurring payment
412
-		if ( ! isset( $param_number ) || 1 == $param_number ) {
412
+        if ( ! isset( $param_number ) || 1 == $param_number ) {
413 413
 
414
-			// Subscription price
415
-			$paypal_args['a3'] = $recurring_amount;
414
+            // Subscription price
415
+            $paypal_args['a3'] = $recurring_amount;
416 416
 
417
-			// Subscription duration
418
-			$paypal_args['p3'] = $interval;
417
+            // Subscription duration
418
+            $paypal_args['p3'] = $interval;
419 419
 
420
-			// Subscription period
421
-			$paypal_args['t3'] = $period;
420
+            // Subscription period
421
+            $paypal_args['t3'] = $period;
422 422
 
423 423
         }
424 424
         
425 425
         // Recurring payments
426
-		if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) {
426
+        if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) {
427 427
 
428
-			// Non-recurring payments
429
-			$paypal_args['src'] = 0;
428
+            // Non-recurring payments
429
+            $paypal_args['src'] = 0;
430 430
 
431
-		} else {
431
+        } else {
432 432
 
433
-			$paypal_args['src'] = 1;
433
+            $paypal_args['src'] = 1;
434 434
 
435
-			if ( $bill_times > 0 ) {
435
+            if ( $bill_times > 0 ) {
436 436
 
437
-				// An initial period is being used to charge a sign-up fee
438
-				if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) {
439
-					$bill_times--;
440
-				}
437
+                // An initial period is being used to charge a sign-up fee
438
+                if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) {
439
+                    $bill_times--;
440
+                }
441 441
 
442 442
                 // Make sure it's not over the max of 52
443 443
                 $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 );
444 444
 
445
-			}
445
+            }
446 446
         }
447 447
         
448 448
         // Force return URL so that order description & instructions display
@@ -458,24 +458,24 @@  discard block
 block discarded – undo
458 458
         }
459 459
 
460 460
         return apply_filters(
461
-			'getpaid_paypal_subscription_args',
462
-			$paypal_args,
463
-			$invoice
461
+            'getpaid_paypal_subscription_args',
462
+            $paypal_args,
463
+            $invoice
464 464
         );
465 465
 
466 466
     }
467 467
 
468 468
     /**
469
-	 * Processes ipns and marks payments as complete.
470
-	 *
471
-	 * @return void
472
-	 */
473
-	public function verify_ipn() {
469
+     * Processes ipns and marks payments as complete.
470
+     *
471
+     * @return void
472
+     */
473
+    public function verify_ipn() {
474 474
 
475 475
         // Validate the IPN.
476 476
         if ( empty( $_POST ) || ! $this->validate_ipn() ) {
477
-		    wp_die( 'PayPal IPN Request Failure', 'PayPal IPN', array( 'response' => 500 ) );
478
-		}
477
+            wp_die( 'PayPal IPN Request Failure', 'PayPal IPN', array( 'response' => 500 ) );
478
+        }
479 479
 
480 480
         // Process the IPN.
481 481
         $posted  = wp_unslash( $_POST );
@@ -483,13 +483,13 @@  discard block
 block discarded – undo
483 483
 
484 484
         if ( $invoice && $this->id == $invoice->get_gateway() ) {
485 485
 
486
-			$posted['payment_status'] = strtolower( $posted['payment_status'] );
486
+            $posted['payment_status'] = strtolower( $posted['payment_status'] );
487 487
 
488 488
             wpinv_error_log( 'Found invoice #' . $invoice->get_number() );
489 489
             wpinv_error_log( 'Payment status:' . $posted['payment_status'] );
490 490
 
491
-			if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) {
492
-				call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted );
491
+            if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) {
492
+                call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted );
493 493
             } else {
494 494
                 wpinv_error_log( 'Aborting, Invalid type:' . $posted['txn_type'] );
495 495
             }
@@ -501,33 +501,33 @@  discard block
 block discarded – undo
501 501
     }
502 502
 
503 503
     /**
504
-	 * Check PayPal IPN validity.
505
-	 */
506
-	public function validate_ipn() {
507
-
508
-		wpinv_error_log( 'Validating PayPal IPN response' );
509
-
510
-		// Get received values from post data.
511
-		$validate_ipn        = wp_unslash( $_POST );
512
-		$validate_ipn['cmd'] = '_notify-validate';
513
-
514
-		// Send back post vars to paypal.
515
-		$params = array(
516
-			'body'        => $validate_ipn,
517
-			'timeout'     => 60,
518
-			'httpversion' => '1.1',
519
-			'compress'    => false,
520
-			'decompress'  => false,
521
-			'user-agent'  => 'GetPaid/' . WPINV_VERSION,
522
-		);
504
+     * Check PayPal IPN validity.
505
+     */
506
+    public function validate_ipn() {
507
+
508
+        wpinv_error_log( 'Validating PayPal IPN response' );
509
+
510
+        // Get received values from post data.
511
+        $validate_ipn        = wp_unslash( $_POST );
512
+        $validate_ipn['cmd'] = '_notify-validate';
513
+
514
+        // Send back post vars to paypal.
515
+        $params = array(
516
+            'body'        => $validate_ipn,
517
+            'timeout'     => 60,
518
+            'httpversion' => '1.1',
519
+            'compress'    => false,
520
+            'decompress'  => false,
521
+            'user-agent'  => 'GetPaid/' . WPINV_VERSION,
522
+        );
523 523
 
524
-		// Post back to get a response.
525
-		$response = wp_safe_remote_post( $this->is_sandbox() ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params );
524
+        // Post back to get a response.
525
+        $response = wp_safe_remote_post( $this->is_sandbox() ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params );
526 526
 
527 527
         // Check to see if the request was valid.
528
-		if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {
528
+        if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {
529 529
             wpinv_error_log( $response['body'], 'Received valid response from PayPal IPN' );
530
-			return true;
530
+            return true;
531 531
         }
532 532
 
533 533
         if ( is_wp_error( $response ) ) {
@@ -541,63 +541,63 @@  discard block
 block discarded – undo
541 541
     }
542 542
 
543 543
     /**
544
-	 * Check currency from IPN matches the invoice.
545
-	 *
546
-	 * @param WPInv_Invoice $invoice          Invoice object.
547
-	 * @param string   $currency currency to validate.
548
-	 */
549
-	protected function validate_ipn_currency( $invoice, $currency ) {
550
-		if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) {
544
+     * Check currency from IPN matches the invoice.
545
+     *
546
+     * @param WPInv_Invoice $invoice          Invoice object.
547
+     * @param string   $currency currency to validate.
548
+     */
549
+    protected function validate_ipn_currency( $invoice, $currency ) {
550
+        if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) {
551 551
             wpinv_record_gateway_error( 'IPN Error', "Currencies do not match: {$currency} instead of {$invoice->get_currency()}" );
552 552
 
553
-			/* translators: %s: currency code. */
554
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) );
555
-			exit;
556
-		}
557
-	}
558
-
559
-	/**
560
-	 * Check payment amount from IPN matches the invoice.
561
-	 *
562
-	 * @param WPInv_Invoice $invoice          Invoice object.
563
-	 * @param float   $amount amount to validate.
564
-	 */
565
-	protected function validate_ipn_amount( $invoice, $amount ) {
566
-		if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
553
+            /* translators: %s: currency code. */
554
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) );
555
+            exit;
556
+        }
557
+    }
558
+
559
+    /**
560
+     * Check payment amount from IPN matches the invoice.
561
+     *
562
+     * @param WPInv_Invoice $invoice          Invoice object.
563
+     * @param float   $amount amount to validate.
564
+     */
565
+    protected function validate_ipn_amount( $invoice, $amount ) {
566
+        if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
567 567
             wpinv_record_gateway_error( 'IPN Error', "Amounts do not match: {$amount} instead of {$invoice->get_total()}" );
568 568
 
569
-			/* translators: %s: Amount. */
570
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) );
571
-			exit;
572
-		}
573
-	}
574
-
575
-	/**
576
-	 * Verify receiver email from PayPal.
577
-	 *
578
-	 * @param WPInv_Invoice $invoice          Invoice object.
579
-	 * @param string   $receiver_email Email to validate.
580
-	 */
581
-	protected function validate_ipn_receiver_email( $invoice, $receiver_email ) {
569
+            /* translators: %s: Amount. */
570
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) );
571
+            exit;
572
+        }
573
+    }
574
+
575
+    /**
576
+     * Verify receiver email from PayPal.
577
+     *
578
+     * @param WPInv_Invoice $invoice          Invoice object.
579
+     * @param string   $receiver_email Email to validate.
580
+     */
581
+    protected function validate_ipn_receiver_email( $invoice, $receiver_email ) {
582 582
         $paypal_email = wpinv_get_option( 'paypal_email' );
583 583
 
584
-		if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) {
584
+        if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) {
585 585
             wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" );
586 586
 
587
-			/* translators: %s: email address . */
588
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) );
589
-			exit;
587
+            /* translators: %s: email address . */
588
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) );
589
+            exit;
590 590
         }
591 591
 
592
-	}
592
+    }
593 593
 
594 594
     /**
595
-	 * Handles one time payments.
596
-	 *
597
-	 * @param WPInv_Invoice $invoice  Invoice object.
598
-	 * @param array    $posted Posted data.
599
-	 */
600
-	protected function ipn_txn_web_accept( $invoice, $posted ) {
595
+     * Handles one time payments.
596
+     *
597
+     * @param WPInv_Invoice $invoice  Invoice object.
598
+     * @param array    $posted Posted data.
599
+     */
600
+    protected function ipn_txn_web_accept( $invoice, $posted ) {
601 601
 
602 602
         // Collect payment details
603 603
         $payment_status = strtolower( $posted['payment_status'] );
@@ -658,27 +658,27 @@  discard block
 block discarded – undo
658 658
         // Process failures.
659 659
 
660 660
         /* translators: %s: payment status. */
661
-		$invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), wpinv_clean( $posted['payment_status'] ) ) );
662
-
663
-	}
664
-
665
-	/**
666
-	 * Handles one time payments.
667
-	 *
668
-	 * @param WPInv_Invoice $invoice  Invoice object.
669
-	 * @param array    $posted Posted data.
670
-	 */
671
-	protected function ipn_txn_cart( $invoice, $posted ) {
672
-		$this->ipn_txn_web_accept( $invoice, $posted );
661
+        $invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), wpinv_clean( $posted['payment_status'] ) ) );
662
+
663
+    }
664
+
665
+    /**
666
+     * Handles one time payments.
667
+     *
668
+     * @param WPInv_Invoice $invoice  Invoice object.
669
+     * @param array    $posted Posted data.
670
+     */
671
+    protected function ipn_txn_cart( $invoice, $posted ) {
672
+        $this->ipn_txn_web_accept( $invoice, $posted );
673 673
     }
674 674
 
675 675
     /**
676
-	 * Handles subscription sign ups.
677
-	 *
678
-	 * @param WPInv_Invoice $invoice  Invoice object.
679
-	 * @param array    $posted Posted data.
680
-	 */
681
-	protected function ipn_txn_subscr_signup( $invoice, $posted ) {
676
+     * Handles subscription sign ups.
677
+     *
678
+     * @param WPInv_Invoice $invoice  Invoice object.
679
+     * @param array    $posted Posted data.
680
+     */
681
+    protected function ipn_txn_subscr_signup( $invoice, $posted ) {
682 682
 
683 683
         // Make sure the invoice has a subscription.
684 684
         $subscription = wpinv_get_subscription( $invoice );
@@ -717,12 +717,12 @@  discard block
 block discarded – undo
717 717
     }
718 718
 
719 719
     /**
720
-	 * Handles subscription renewals.
721
-	 *
722
-	 * @param WPInv_Invoice $invoice  Invoice object.
723
-	 * @param array    $posted Posted data.
724
-	 */
725
-	protected function ipn_txn_subscr_payment( $invoice, $posted ) {
720
+     * Handles subscription renewals.
721
+     *
722
+     * @param WPInv_Invoice $invoice  Invoice object.
723
+     * @param array    $posted Posted data.
724
+     */
725
+    protected function ipn_txn_subscr_payment( $invoice, $posted ) {
726 726
 
727 727
         // Make sure the invoice has a subscription.
728 728
         $subscription = wpinv_get_subscription( $invoice );
@@ -765,12 +765,12 @@  discard block
 block discarded – undo
765 765
     }
766 766
 
767 767
     /**
768
-	 * Handles subscription cancelations.
769
-	 *
770
-	 * @param WPInv_Invoice $invoice  Invoice object.
771
-	 * @param array    $posted Posted data.
772
-	 */
773
-	protected function ipn_txn_subscr_cancel( $invoice, $posted ) {
768
+     * Handles subscription cancelations.
769
+     *
770
+     * @param WPInv_Invoice $invoice  Invoice object.
771
+     * @param array    $posted Posted data.
772
+     */
773
+    protected function ipn_txn_subscr_cancel( $invoice, $posted ) {
774 774
 
775 775
         if ( $subscription = wpinv_get_subscription( $invoice ) ) {
776 776
             $subscription->cancel();
@@ -779,12 +779,12 @@  discard block
 block discarded – undo
779 779
     }
780 780
 
781 781
     /**
782
-	 * Handles subscription completions.
783
-	 *
784
-	 * @param WPInv_Invoice $invoice  Invoice object.
785
-	 * @param array    $posted Posted data.
786
-	 */
787
-	protected function ipn_txn_subscr_eot( $invoice, $posted ) {
782
+     * Handles subscription completions.
783
+     *
784
+     * @param WPInv_Invoice $invoice  Invoice object.
785
+     * @param array    $posted Posted data.
786
+     */
787
+    protected function ipn_txn_subscr_eot( $invoice, $posted ) {
788 788
 
789 789
         if ( $subscription = wpinv_get_subscription( $invoice ) ) {
790 790
             $subscription->complete();
@@ -793,12 +793,12 @@  discard block
 block discarded – undo
793 793
     }
794 794
 
795 795
     /**
796
-	 * Handles subscription fails.
797
-	 *
798
-	 * @param WPInv_Invoice $invoice  Invoice object.
799
-	 * @param array    $posted Posted data.
800
-	 */
801
-	protected function ipn_txn_subscr_failed( $invoice, $posted ) {
796
+     * Handles subscription fails.
797
+     *
798
+     * @param WPInv_Invoice $invoice  Invoice object.
799
+     * @param array    $posted Posted data.
800
+     */
801
+    protected function ipn_txn_subscr_failed( $invoice, $posted ) {
802 802
 
803 803
         if ( $subscription = wpinv_get_subscription( $invoice ) ) {
804 804
             $subscription->failing();
Please login to merge, or discard this patch.
Spacing   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Paypal Payment Gateway class.
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @var array
26 26
 	 */
27
-    protected $supports = array( 'subscription', 'sandbox' );
27
+    protected $supports = array('subscription', 'sandbox');
28 28
 
29 29
     /**
30 30
 	 * Payment method order.
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @var array
61 61
 	 */
62
-	public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' );
62
+	public $currencies = array('AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR');
63 63
 
64 64
     /**
65 65
 	 * URL to view a transaction.
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function __construct() {
82 82
 
83
-        $this->title             = __( 'PayPal Standard', 'invoicing' );
84
-        $this->method_title      = __( 'PayPal Standard', 'invoicing' );
85
-        $this->order_button_text = __( 'Proceed to PayPal', 'invoicing' );
86
-        $this->notify_url        = wpinv_get_ipn_url( $this->id );
83
+        $this->title             = __('PayPal Standard', 'invoicing');
84
+        $this->method_title      = __('PayPal Standard', 'invoicing');
85
+        $this->order_button_text = __('Proceed to PayPal', 'invoicing');
86
+        $this->notify_url        = wpinv_get_ipn_url($this->id);
87 87
 
88
-        add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 );
89
-        add_filter( 'wpinv_gateway_description', array( $this, 'sandbox_notice' ), 10, 2 );
88
+        add_filter('getpaid_paypal_args', array($this, 'process_subscription'), 10, 2);
89
+        add_filter('wpinv_gateway_description', array($this, 'sandbox_notice'), 10, 2);
90 90
 
91 91
         parent::__construct();
92 92
     }
@@ -100,16 +100,16 @@  discard block
 block discarded – undo
100 100
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
101 101
 	 * @return array
102 102
 	 */
103
-	public function process_payment( $invoice, $submission_data, $submission ) {
103
+	public function process_payment($invoice, $submission_data, $submission) {
104 104
 
105 105
         // Get redirect url.
106
-        $paypal_redirect = $this->get_request_url( $invoice );
106
+        $paypal_redirect = $this->get_request_url($invoice);
107 107
 
108 108
         // Add a note about the request url.
109 109
         $invoice->add_note(
110 110
             sprintf(
111
-                __( 'Redirecting to PayPal: %s', 'invoicing' ),
112
-                esc_url( $paypal_redirect )
111
+                __('Redirecting to PayPal: %s', 'invoicing'),
112
+                esc_url($paypal_redirect)
113 113
             ),
114 114
             false,
115 115
             false,
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
         );
118 118
 
119 119
         // Redirect to PayPal
120
-        wp_redirect( $paypal_redirect );
120
+        wp_redirect($paypal_redirect);
121 121
         exit;
122 122
 
123 123
     }
@@ -128,21 +128,21 @@  discard block
 block discarded – undo
128 128
 	 * @param  WPInv_Invoice $invoice Invoice object.
129 129
 	 * @return string
130 130
 	 */
131
-	public function get_request_url( $invoice ) {
131
+	public function get_request_url($invoice) {
132 132
 
133 133
         // Endpoint for this request
134
-		$this->endpoint    = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
134
+		$this->endpoint = $this->is_sandbox($invoice) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
135 135
 
136 136
         // Retrieve paypal args.
137
-        $paypal_args       = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' );
137
+        $paypal_args = map_deep($this->get_paypal_args($invoice), 'urlencode');
138 138
 
139
-        if ( $invoice->is_recurring() ) {
139
+        if ($invoice->is_recurring()) {
140 140
             $paypal_args['bn'] = 'GetPaid_Subscribe_WPS_US';
141 141
         } else {
142 142
             $paypal_args['bn'] = 'GetPaid_ShoppingCart_WPS_US';
143 143
         }
144 144
 
145
-        return add_query_arg( $paypal_args, $this->endpoint );
145
+        return add_query_arg($paypal_args, $this->endpoint);
146 146
 
147 147
 	}
148 148
 
@@ -152,25 +152,25 @@  discard block
 block discarded – undo
152 152
 	 * @param  WPInv_Invoice $invoice Invoice object.
153 153
 	 * @return array
154 154
 	 */
155
-	protected function get_paypal_args( $invoice ) {
155
+	protected function get_paypal_args($invoice) {
156 156
 
157 157
         // Whether or not to send the line items as one item.
158
-		$force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', false, $invoice );
158
+		$force_one_line_item = apply_filters('getpaid_paypal_force_one_line_item', false, $invoice);
159 159
 
160
-		if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) {
160
+		if ($invoice->is_recurring() || (wpinv_use_taxes() && wpinv_prices_include_tax())) {
161 161
 			$force_one_line_item = true;
162 162
 		}
163 163
 
164 164
 		$paypal_args = apply_filters(
165 165
 			'getpaid_paypal_args',
166 166
 			array_merge(
167
-				$this->get_transaction_args( $invoice ),
168
-				$this->get_line_item_args( $invoice, $force_one_line_item )
167
+				$this->get_transaction_args($invoice),
168
+				$this->get_line_item_args($invoice, $force_one_line_item)
169 169
 			),
170 170
 			$invoice
171 171
 		);
172 172
 
173
-		return $this->fix_request_length( $invoice, $paypal_args );
173
+		return $this->fix_request_length($invoice, $paypal_args);
174 174
     }
175 175
 
176 176
     /**
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
 	 * @param WPInv_Invoice $invoice Invoice object.
180 180
 	 * @return array
181 181
 	 */
182
-	protected function get_transaction_args( $invoice ) {
182
+	protected function get_transaction_args($invoice) {
183 183
 
184 184
 		return array(
185 185
             'cmd'           => '_cart',
186
-            'business'      => wpinv_get_option( 'paypal_email', false ),
186
+            'business'      => wpinv_get_option('paypal_email', false),
187 187
             'no_shipping'   => '1',
188 188
             'shipping'      => '0',
189 189
             'no_note'       => '1',
@@ -191,16 +191,16 @@  discard block
 block discarded – undo
191 191
             'rm'            => is_ssl() ? 2 : 1,
192 192
             'upload'        => 1,
193 193
             'currency_code' => $invoice->get_currency(), // https://developer.paypal.com/docs/nvp-soap-api/currency-codes/#paypal
194
-            'return'        => esc_url_raw( $this->get_return_url( $invoice ) ),
195
-            'cancel_return' => esc_url_raw( $invoice->get_checkout_payment_url() ),
196
-            'notify_url'    => getpaid_limit_length( $this->notify_url, 255 ),
197
-            'invoice'       => getpaid_limit_length( $invoice->get_number(), 127 ),
194
+            'return'        => esc_url_raw($this->get_return_url($invoice)),
195
+            'cancel_return' => esc_url_raw($invoice->get_checkout_payment_url()),
196
+            'notify_url'    => getpaid_limit_length($this->notify_url, 255),
197
+            'invoice'       => getpaid_limit_length($invoice->get_number(), 127),
198 198
             'custom'        => $invoice->get_id(),
199
-            'first_name'    => getpaid_limit_length( $invoice->get_first_name(), 32 ),
200
-            'last_name'     => getpaid_limit_length( $invoice->get_last_name(), 64 ),
201
-            'country'       => getpaid_limit_length( $invoice->get_country(), 2 ),
202
-            'email'         => getpaid_limit_length( $invoice->get_email(), 127 ),
203
-            'cbt'           => get_bloginfo( 'name' )
199
+            'first_name'    => getpaid_limit_length($invoice->get_first_name(), 32),
200
+            'last_name'     => getpaid_limit_length($invoice->get_last_name(), 64),
201
+            'country'       => getpaid_limit_length($invoice->get_country(), 2),
202
+            'email'         => getpaid_limit_length($invoice->get_email(), 127),
203
+            'cbt'           => get_bloginfo('name')
204 204
         );
205 205
 
206 206
     }
@@ -212,30 +212,30 @@  discard block
 block discarded – undo
212 212
 	 * @param  bool     $force_one_line_item Create only one item for this invoice.
213 213
 	 * @return array
214 214
 	 */
215
-	protected function get_line_item_args( $invoice, $force_one_line_item = false ) {
215
+	protected function get_line_item_args($invoice, $force_one_line_item = false) {
216 216
 
217 217
         // Maybe send invoice as a single item.
218
-		if ( $force_one_line_item ) {
219
-            return $this->get_line_item_args_single_item( $invoice );
218
+		if ($force_one_line_item) {
219
+            return $this->get_line_item_args_single_item($invoice);
220 220
         }
221 221
 
222 222
         // Send each line item individually.
223 223
         $line_item_args = array();
224 224
 
225 225
         // Prepare line items.
226
-        $this->prepare_line_items( $invoice );
226
+        $this->prepare_line_items($invoice);
227 227
 
228 228
         // Add taxes to the cart
229
-        if ( wpinv_use_taxes() && $invoice->is_taxable() ) {
230
-            $line_item_args['tax_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_tax(), 2 );
229
+        if (wpinv_use_taxes() && $invoice->is_taxable()) {
230
+            $line_item_args['tax_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_tax(), 2);
231 231
         }
232 232
 
233 233
         // Add discount.
234
-        if ( $invoice->get_total_discount() > 0 ) {
235
-            $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 );
234
+        if ($invoice->get_total_discount() > 0) {
235
+            $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_discount(), 2);
236 236
         }
237 237
 
238
-		return array_merge( $line_item_args, $this->get_line_items() );
238
+		return array_merge($line_item_args, $this->get_line_items());
239 239
 
240 240
     }
241 241
 
@@ -245,11 +245,11 @@  discard block
 block discarded – undo
245 245
 	 * @param  WPInv_Invoice $invoice Invoice object.
246 246
 	 * @return array
247 247
 	 */
248
-	protected function get_line_item_args_single_item( $invoice ) {
248
+	protected function get_line_item_args_single_item($invoice) {
249 249
 		$this->delete_line_items();
250 250
 
251
-        $item_name = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() );
252
-		$this->add_line_item( $item_name, 1, wpinv_sanitize_amount( (float) $invoice->get_total(), 2 ), $invoice->get_id() );
251
+        $item_name = sprintf(__('Invoice #%s', 'invoicing'), $invoice->get_number());
252
+		$this->add_line_item($item_name, 1, wpinv_sanitize_amount((float) $invoice->get_total(), 2), $invoice->get_id());
253 253
 
254 254
 		return $this->get_line_items();
255 255
     }
@@ -273,19 +273,19 @@  discard block
 block discarded – undo
273 273
 	 *
274 274
 	 * @param  WPInv_Invoice $invoice Invoice object.
275 275
 	 */
276
-	protected function prepare_line_items( $invoice ) {
276
+	protected function prepare_line_items($invoice) {
277 277
 		$this->delete_line_items();
278 278
 
279 279
 		// Items.
280
-		foreach ( $invoice->get_items() as $item ) {
280
+		foreach ($invoice->get_items() as $item) {
281 281
 			$amount   = $invoice->get_template() == 'amount' ? $item->get_price() : $item->get_sub_total();
282 282
 			$quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity();
283
-			$this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() );
283
+			$this->add_line_item($item->get_raw_name(), $quantity, $amount, $item->get_id());
284 284
         }
285 285
 
286 286
         // Fees.
287
-		foreach ( $invoice->get_fees() as $fee => $data ) {
288
-            $this->add_line_item( $fee, 1, $data['amount'] );
287
+		foreach ($invoice->get_fees() as $fee => $data) {
288
+            $this->add_line_item($fee, 1, $data['amount']);
289 289
         }
290 290
 
291 291
     }
@@ -298,15 +298,15 @@  discard block
 block discarded – undo
298 298
 	 * @param  float  $amount Amount.
299 299
 	 * @param  string $item_number Item number.
300 300
 	 */
301
-	protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) {
302
-		$index = ( count( $this->line_items ) / 4 ) + 1;
301
+	protected function add_line_item($item_name, $quantity = 1, $amount = 0.0, $item_number = '') {
302
+		$index = (count($this->line_items) / 4) + 1;
303 303
 
304 304
 		$item = apply_filters(
305 305
 			'getpaid_paypal_line_item',
306 306
 			array(
307
-				'item_name'   => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
307
+				'item_name'   => html_entity_decode(getpaid_limit_length($item_name ? wp_strip_all_tags($item_name) : __('Item', 'invoicing'), 127), ENT_NOQUOTES, 'UTF-8'),
308 308
 				'quantity'    => (int) $quantity,
309
-				'amount'      => wpinv_sanitize_amount( (float) $amount, 2 ),
309
+				'amount'      => wpinv_sanitize_amount((float) $amount, 2),
310 310
 				'item_number' => $item_number,
311 311
 			),
312 312
 			$item_name,
@@ -315,12 +315,12 @@  discard block
 block discarded – undo
315 315
 			$item_number
316 316
 		);
317 317
 
318
-		$this->line_items[ 'item_name_' . $index ]   = getpaid_limit_length( $item['item_name'], 127 );
319
-        $this->line_items[ 'quantity_' . $index ]    = $item['quantity'];
318
+		$this->line_items['item_name_' . $index] = getpaid_limit_length($item['item_name'], 127);
319
+        $this->line_items['quantity_' . $index] = $item['quantity'];
320 320
         
321 321
         // The price or amount of the product, service, or contribution, not including shipping, handling, or tax.
322
-		$this->line_items[ 'amount_' . $index ]      = $item['amount'];
323
-		$this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 );
322
+		$this->line_items['amount_' . $index]      = $item['amount'];
323
+		$this->line_items['item_number_' . $index] = getpaid_limit_length($item['item_number'], 127);
324 324
     }
325 325
 
326 326
     /**
@@ -332,19 +332,19 @@  discard block
 block discarded – undo
332 332
 	 * @param array    $paypal_args Arguments sent to Paypal in the request.
333 333
 	 * @return array
334 334
 	 */
335
-	protected function fix_request_length( $invoice, $paypal_args ) {
335
+	protected function fix_request_length($invoice, $paypal_args) {
336 336
 		$max_paypal_length = 2083;
337
-		$query_candidate   = http_build_query( $paypal_args, '', '&' );
337
+		$query_candidate   = http_build_query($paypal_args, '', '&');
338 338
 
339
-		if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) {
339
+		if (strlen($this->endpoint . $query_candidate) <= $max_paypal_length) {
340 340
 			return $paypal_args;
341 341
 		}
342 342
 
343 343
 		return apply_filters(
344 344
 			'getpaid_paypal_args',
345 345
 			array_merge(
346
-				$this->get_transaction_args( $invoice ),
347
-				$this->get_line_item_args( $invoice, true )
346
+				$this->get_transaction_args($invoice),
347
+				$this->get_line_item_args($invoice, true)
348 348
 			),
349 349
 			$invoice
350 350
 		);
@@ -357,10 +357,10 @@  discard block
 block discarded – undo
357 357
 	 * @param  array $paypal_args PayPal args.
358 358
 	 * @param  WPInv_Invoice    $invoice Invoice object.
359 359
 	 */
360
-	public function process_subscription( $paypal_args, $invoice ) {
360
+	public function process_subscription($paypal_args, $invoice) {
361 361
 
362 362
         // Make sure this is a subscription.
363
-        if ( ! $invoice->is_recurring() || ! $subscription = wpinv_get_subscription( $invoice ) ) {
363
+        if (!$invoice->is_recurring() || !$subscription = wpinv_get_subscription($invoice)) {
364 364
             return $paypal_args;
365 365
         }
366 366
 
@@ -368,17 +368,17 @@  discard block
 block discarded – undo
368 368
         $paypal_args['cmd'] = '_xclick-subscriptions';
369 369
 
370 370
         // Subscription name.
371
-        $paypal_args['item_name'] = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() );
371
+        $paypal_args['item_name'] = sprintf(__('Invoice #%s', 'invoicing'), $invoice->get_number());
372 372
 
373 373
         // Get subscription args.
374
-        $period                 = strtoupper( substr( $subscription->period, 0, 1) );
374
+        $period                 = strtoupper(substr($subscription->period, 0, 1));
375 375
         $interval               = (int) $subscription->frequency;
376 376
         $bill_times             = (int) $subscription->bill_times;
377
-        $initial_amount         = (float) wpinv_sanitize_amount( $invoice->get_initial_total(), 2 );
378
-        $recurring_amount       = (float) wpinv_sanitize_amount( $invoice->get_recurring_total(), 2 );
379
-        $subscription_item      = $invoice->get_recurring( true );
377
+        $initial_amount         = (float) wpinv_sanitize_amount($invoice->get_initial_total(), 2);
378
+        $recurring_amount       = (float) wpinv_sanitize_amount($invoice->get_recurring_total(), 2);
379
+        $subscription_item      = $invoice->get_recurring(true);
380 380
 
381
-        if ( $subscription_item->has_free_trial() ) {
381
+        if ($subscription_item->has_free_trial()) {
382 382
 
383 383
             $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount;
384 384
 
@@ -388,28 +388,28 @@  discard block
 block discarded – undo
388 388
 			// Trial period.
389 389
 			$paypal_args['t1'] = $subscription_item->get_trial_period();
390 390
 
391
-        } else if ( $initial_amount != $recurring_amount ) {
391
+        } else if ($initial_amount != $recurring_amount) {
392 392
 
393 393
             // No trial period, but initial amount includes a sign-up fee and/or other items, so charge it as a separate period.
394 394
 
395
-            if ( 1 == $bill_times ) {
395
+            if (1 == $bill_times) {
396 396
                 $param_number = 3;
397 397
             } else {
398 398
                 $param_number = 1;
399 399
             }
400 400
 
401
-            $paypal_args[ 'a' . $param_number ] = $initial_amount ? 0 : $initial_amount;
401
+            $paypal_args['a' . $param_number] = $initial_amount ? 0 : $initial_amount;
402 402
 
403 403
             // Sign Up interval
404
-            $paypal_args[ 'p' . $param_number ] = $interval;
404
+            $paypal_args['p' . $param_number] = $interval;
405 405
 
406 406
             // Sign Up unit of duration
407
-            $paypal_args[ 't' . $param_number ] = $period;
407
+            $paypal_args['t' . $param_number] = $period;
408 408
 
409 409
         }
410 410
 
411 411
         // We have a recurring payment
412
-		if ( ! isset( $param_number ) || 1 == $param_number ) {
412
+		if (!isset($param_number) || 1 == $param_number) {
413 413
 
414 414
 			// Subscription price
415 415
 			$paypal_args['a3'] = $recurring_amount;
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
         }
424 424
         
425 425
         // Recurring payments
426
-		if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) {
426
+		if (1 == $bill_times || ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial() && 2 == $bill_times)) {
427 427
 
428 428
 			// Non-recurring payments
429 429
 			$paypal_args['src'] = 0;
@@ -432,15 +432,15 @@  discard block
 block discarded – undo
432 432
 
433 433
 			$paypal_args['src'] = 1;
434 434
 
435
-			if ( $bill_times > 0 ) {
435
+			if ($bill_times > 0) {
436 436
 
437 437
 				// An initial period is being used to charge a sign-up fee
438
-				if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) {
438
+				if ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial()) {
439 439
 					$bill_times--;
440 440
 				}
441 441
 
442 442
                 // Make sure it's not over the max of 52
443
-                $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 );
443
+                $paypal_args['srt'] = ($bill_times <= 52 ? absint($bill_times) : 52);
444 444
 
445 445
 			}
446 446
         }
@@ -449,10 +449,10 @@  discard block
 block discarded – undo
449 449
         $paypal_args['rm'] = 2;
450 450
         
451 451
         // Get rid of redudant items.
452
-        foreach ( array( 'item_name_1', 'quantity_1', 'amount_1', 'item_number_1' ) as $arg ) {
452
+        foreach (array('item_name_1', 'quantity_1', 'amount_1', 'item_number_1') as $arg) {
453 453
 
454
-            if ( isset( $paypal_args[ $arg ] ) ) {
455
-                unset( $paypal_args[ $arg ] );
454
+            if (isset($paypal_args[$arg])) {
455
+                unset($paypal_args[$arg]);
456 456
             }
457 457
 
458 458
         }
@@ -473,25 +473,25 @@  discard block
 block discarded – undo
473 473
 	public function verify_ipn() {
474 474
 
475 475
         // Validate the IPN.
476
-        if ( empty( $_POST ) || ! $this->validate_ipn() ) {
477
-		    wp_die( 'PayPal IPN Request Failure', 'PayPal IPN', array( 'response' => 500 ) );
476
+        if (empty($_POST) || !$this->validate_ipn()) {
477
+		    wp_die('PayPal IPN Request Failure', 'PayPal IPN', array('response' => 500));
478 478
 		}
479 479
 
480 480
         // Process the IPN.
481
-        $posted  = wp_unslash( $_POST );
482
-        $invoice = wpinv_get_invoice( $posted['custom'] );
481
+        $posted  = wp_unslash($_POST);
482
+        $invoice = wpinv_get_invoice($posted['custom']);
483 483
 
484
-        if ( $invoice && $this->id == $invoice->get_gateway() ) {
484
+        if ($invoice && $this->id == $invoice->get_gateway()) {
485 485
 
486
-			$posted['payment_status'] = strtolower( $posted['payment_status'] );
486
+			$posted['payment_status'] = strtolower($posted['payment_status']);
487 487
 
488
-            wpinv_error_log( 'Found invoice #' . $invoice->get_number() );
489
-            wpinv_error_log( 'Payment status:' . $posted['payment_status'] );
488
+            wpinv_error_log('Found invoice #' . $invoice->get_number());
489
+            wpinv_error_log('Payment status:' . $posted['payment_status']);
490 490
 
491
-			if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) {
492
-				call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted );
491
+			if (method_exists($this, 'ipn_txn_' . $posted['txn_type'])) {
492
+				call_user_func(array($this, 'ipn_txn_' . $posted['txn_type']), $invoice, $posted);
493 493
             } else {
494
-                wpinv_error_log( 'Aborting, Invalid type:' . $posted['txn_type'] );
494
+                wpinv_error_log('Aborting, Invalid type:' . $posted['txn_type']);
495 495
             }
496 496
 
497 497
         }
@@ -505,10 +505,10 @@  discard block
 block discarded – undo
505 505
 	 */
506 506
 	public function validate_ipn() {
507 507
 
508
-		wpinv_error_log( 'Validating PayPal IPN response' );
508
+		wpinv_error_log('Validating PayPal IPN response');
509 509
 
510 510
 		// Get received values from post data.
511
-		$validate_ipn        = wp_unslash( $_POST );
511
+		$validate_ipn        = wp_unslash($_POST);
512 512
 		$validate_ipn['cmd'] = '_notify-validate';
513 513
 
514 514
 		// Send back post vars to paypal.
@@ -522,18 +522,18 @@  discard block
 block discarded – undo
522 522
 		);
523 523
 
524 524
 		// Post back to get a response.
525
-		$response = wp_safe_remote_post( $this->is_sandbox() ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params );
525
+		$response = wp_safe_remote_post($this->is_sandbox() ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params);
526 526
 
527 527
         // Check to see if the request was valid.
528
-		if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {
529
-            wpinv_error_log( $response['body'], 'Received valid response from PayPal IPN' );
528
+		if (!is_wp_error($response) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 && strstr($response['body'], 'VERIFIED')) {
529
+            wpinv_error_log($response['body'], 'Received valid response from PayPal IPN');
530 530
 			return true;
531 531
         }
532 532
 
533
-        if ( is_wp_error( $response ) ) {
534
-            wpinv_error_log( $response->get_error_message(), 'Received invalid response from PayPal IPN' );
533
+        if (is_wp_error($response)) {
534
+            wpinv_error_log($response->get_error_message(), 'Received invalid response from PayPal IPN');
535 535
         } else {
536
-            wpinv_error_log( $response['body'], 'Received invalid response from PayPal IPN' );
536
+            wpinv_error_log($response['body'], 'Received invalid response from PayPal IPN');
537 537
         }
538 538
 
539 539
         return false;
@@ -546,12 +546,12 @@  discard block
 block discarded – undo
546 546
 	 * @param WPInv_Invoice $invoice          Invoice object.
547 547
 	 * @param string   $currency currency to validate.
548 548
 	 */
549
-	protected function validate_ipn_currency( $invoice, $currency ) {
550
-		if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) {
551
-            wpinv_record_gateway_error( 'IPN Error', "Currencies do not match: {$currency} instead of {$invoice->get_currency()}" );
549
+	protected function validate_ipn_currency($invoice, $currency) {
550
+		if (strtolower($invoice->get_currency()) !== strtolower($currency)) {
551
+            wpinv_record_gateway_error('IPN Error', "Currencies do not match: {$currency} instead of {$invoice->get_currency()}");
552 552
 
553 553
 			/* translators: %s: currency code. */
554
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) );
554
+			$invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal currencies do not match (code %s).', 'invoicing'), $currency));
555 555
 			exit;
556 556
 		}
557 557
 	}
@@ -562,12 +562,12 @@  discard block
 block discarded – undo
562 562
 	 * @param WPInv_Invoice $invoice          Invoice object.
563 563
 	 * @param float   $amount amount to validate.
564 564
 	 */
565
-	protected function validate_ipn_amount( $invoice, $amount ) {
566
-		if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
567
-            wpinv_record_gateway_error( 'IPN Error', "Amounts do not match: {$amount} instead of {$invoice->get_total()}" );
565
+	protected function validate_ipn_amount($invoice, $amount) {
566
+		if (number_format($invoice->get_total(), 2, '.', '') !== number_format($amount, 2, '.', '')) {
567
+            wpinv_record_gateway_error('IPN Error', "Amounts do not match: {$amount} instead of {$invoice->get_total()}");
568 568
 
569 569
 			/* translators: %s: Amount. */
570
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) );
570
+			$invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal amounts do not match (gross %s).', 'invoicing'), $amount));
571 571
 			exit;
572 572
 		}
573 573
 	}
@@ -578,14 +578,14 @@  discard block
 block discarded – undo
578 578
 	 * @param WPInv_Invoice $invoice          Invoice object.
579 579
 	 * @param string   $receiver_email Email to validate.
580 580
 	 */
581
-	protected function validate_ipn_receiver_email( $invoice, $receiver_email ) {
582
-        $paypal_email = wpinv_get_option( 'paypal_email' );
581
+	protected function validate_ipn_receiver_email($invoice, $receiver_email) {
582
+        $paypal_email = wpinv_get_option('paypal_email');
583 583
 
584
-		if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) {
585
-            wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" );
584
+		if (strcasecmp(trim($receiver_email), trim($paypal_email)) !== 0) {
585
+            wpinv_record_gateway_error('IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}");
586 586
 
587 587
 			/* translators: %s: email address . */
588
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) );
588
+			$invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal IPN response from a different email address (%s).', 'invoicing'), $receiver_email));
589 589
 			exit;
590 590
         }
591 591
 
@@ -597,57 +597,57 @@  discard block
 block discarded – undo
597 597
 	 * @param WPInv_Invoice $invoice  Invoice object.
598 598
 	 * @param array    $posted Posted data.
599 599
 	 */
600
-	protected function ipn_txn_web_accept( $invoice, $posted ) {
600
+	protected function ipn_txn_web_accept($invoice, $posted) {
601 601
 
602 602
         // Collect payment details
603
-        $payment_status = strtolower( $posted['payment_status'] );
604
-        $business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
603
+        $payment_status = strtolower($posted['payment_status']);
604
+        $business_email = isset($posted['business']) && is_email($posted['business']) ? trim($posted['business']) : trim($posted['receiver_email']);
605 605
 
606
-        $this->validate_ipn_receiver_email( $invoice, $business_email );
607
-        $this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
606
+        $this->validate_ipn_receiver_email($invoice, $business_email);
607
+        $this->validate_ipn_currency($invoice, $posted['mc_currency']);
608 608
 
609 609
         // Update the transaction id.
610
-        if ( ! empty( $posted['txn_id'] ) ) {
611
-            $invoice->set_transaction_id( wpinv_clean( $posted['txn_id'] ) );
610
+        if (!empty($posted['txn_id'])) {
611
+            $invoice->set_transaction_id(wpinv_clean($posted['txn_id']));
612 612
             $invoice->save();
613 613
         }
614 614
 
615 615
         // Process a refund.
616
-        if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
616
+        if ($payment_status == 'refunded' || $payment_status == 'reversed') {
617 617
 
618
-            update_post_meta( $invoice->get_id(), 'refunded_remotely', 1 );
618
+            update_post_meta($invoice->get_id(), 'refunded_remotely', 1);
619 619
 
620
-            if ( ! $invoice->is_refunded() ) {
621
-                $invoice->update_status( 'wpi-refunded', $posted['reason_code'] );
620
+            if (!$invoice->is_refunded()) {
621
+                $invoice->update_status('wpi-refunded', $posted['reason_code']);
622 622
             }
623 623
 
624 624
             exit;
625 625
         }
626 626
 
627 627
         // Process payments.
628
-        if ( $payment_status == 'completed' ) {
628
+        if ($payment_status == 'completed') {
629 629
 
630
-            if ( $invoice->is_paid() && 'wpi_processing' != $invoice->get_status() ) {
631
-                wpinv_error_log( 'Aborting, Invoice #' . $invoice->get_number() . ' is already complete.' );
630
+            if ($invoice->is_paid() && 'wpi_processing' != $invoice->get_status()) {
631
+                wpinv_error_log('Aborting, Invoice #' . $invoice->get_number() . ' is already complete.');
632 632
                 exit;
633 633
             }
634 634
 
635
-            $this->validate_ipn_amount( $invoice, $posted['mc_gross'] );
635
+            $this->validate_ipn_amount($invoice, $posted['mc_gross']);
636 636
 
637
-            if ( 'completed' === $payment_status || 'pending' === $payment_status ) {
637
+            if ('completed' === $payment_status || 'pending' === $payment_status) {
638 638
 
639 639
                 $note = '';
640 640
 
641
-                if ( ! empty( $posted['mc_fee'] ) ) {
642
-                    $note = sprintf( __( 'PayPal Transaction Fee %s', 'invoicing' ), wpinv_clean( $posted['mc_fee'] ) );
641
+                if (!empty($posted['mc_fee'])) {
642
+                    $note = sprintf(__('PayPal Transaction Fee %s', 'invoicing'), wpinv_clean($posted['mc_fee']));
643 643
                 }
644 644
 
645
-                $invoice->mark_paid( ( ! empty( $posted['txn_id'] ) ? wpinv_clean( $posted['txn_id'] ) : '' ), $note );
645
+                $invoice->mark_paid((!empty($posted['txn_id']) ? wpinv_clean($posted['txn_id']) : ''), $note);
646 646
 
647 647
             } else {
648 648
 
649 649
                 /* translators: %s: pending reason. */
650
-                $invoice->update_status( 'wpi_processing', sprintf( __( 'Payment pending (%s).', 'invoicing' ), $posted['pending_reason'] ) );
650
+                $invoice->update_status('wpi_processing', sprintf(__('Payment pending (%s).', 'invoicing'), $posted['pending_reason']));
651 651
 
652 652
             }
653 653
 
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
         // Process failures.
659 659
 
660 660
         /* translators: %s: payment status. */
661
-		$invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), wpinv_clean( $posted['payment_status'] ) ) );
661
+		$invoice->update_status('wpi-failed', sprintf(__('Payment %s via IPN.', 'invoicing'), wpinv_clean($posted['payment_status'])));
662 662
 
663 663
 	}
664 664
 
@@ -668,8 +668,8 @@  discard block
 block discarded – undo
668 668
 	 * @param WPInv_Invoice $invoice  Invoice object.
669 669
 	 * @param array    $posted Posted data.
670 670
 	 */
671
-	protected function ipn_txn_cart( $invoice, $posted ) {
672
-		$this->ipn_txn_web_accept( $invoice, $posted );
671
+	protected function ipn_txn_cart($invoice, $posted) {
672
+		$this->ipn_txn_web_accept($invoice, $posted);
673 673
     }
674 674
 
675 675
     /**
@@ -678,39 +678,39 @@  discard block
 block discarded – undo
678 678
 	 * @param WPInv_Invoice $invoice  Invoice object.
679 679
 	 * @param array    $posted Posted data.
680 680
 	 */
681
-	protected function ipn_txn_subscr_signup( $invoice, $posted ) {
681
+	protected function ipn_txn_subscr_signup($invoice, $posted) {
682 682
 
683 683
         // Make sure the invoice has a subscription.
684
-        $subscription = wpinv_get_subscription( $invoice );
684
+        $subscription = wpinv_get_subscription($invoice);
685 685
 
686
-        if ( empty( $subscription ) ) {
687
-            wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found' );
686
+        if (empty($subscription)) {
687
+            wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found');
688 688
         }
689 689
 
690 690
         // Update the subscription ids.
691 691
         $subscription->update(
692 692
             array(
693
-                'profile_id' => sanitize_text_field( $posted['subscr_id'] ),
693
+                'profile_id' => sanitize_text_field($posted['subscr_id']),
694 694
             )
695 695
         );
696 696
 
697 697
         // Set the transaction id.
698
-        if ( ! empty( $posted['txn_id'] ) ) {
699
-            $invoice->set_transaction_id( $posted['txn_id'] );
698
+        if (!empty($posted['txn_id'])) {
699
+            $invoice->set_transaction_id($posted['txn_id']);
700 700
         }
701 701
 
702 702
         // Update the payment status.
703 703
         $invoice->mark_paid();
704 704
 
705
-        $invoice->add_note( sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
705
+        $invoice->add_note(sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $posted['subscr_id']), false, false, true);
706 706
 
707 707
         // Use the action id as the subscription id.
708
-        $duration = strtotime( $subscription->expiration ) - strtotime( $subscription->created );
708
+        $duration = strtotime($subscription->expiration) - strtotime($subscription->created);
709 709
         $subscription->update( 
710 710
             array(
711 711
                 'status'     => 'trialling' == $subscription->status ? 'trialling' : 'active',
712
-                'created'    => current_time( 'mysql' ),
713
-                'expiration' => date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ),
712
+                'created'    => current_time('mysql'),
713
+                'expiration' => date('Y-m-d H:i:s', (current_time('timestamp') + $duration)),
714 714
             )
715 715
         );
716 716
 
@@ -722,25 +722,25 @@  discard block
 block discarded – undo
722 722
 	 * @param WPInv_Invoice $invoice  Invoice object.
723 723
 	 * @param array    $posted Posted data.
724 724
 	 */
725
-	protected function ipn_txn_subscr_payment( $invoice, $posted ) {
725
+	protected function ipn_txn_subscr_payment($invoice, $posted) {
726 726
 
727 727
         // Make sure the invoice has a subscription.
728
-        $subscription = wpinv_get_subscription( $invoice );
728
+        $subscription = wpinv_get_subscription($invoice);
729 729
 
730
-        if ( empty( $subscription ) ) {
731
-            wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found' );
730
+        if (empty($subscription)) {
731
+            wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found');
732 732
         }
733 733
 
734
-        $this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
734
+        $this->validate_ipn_currency($invoice, $posted['mc_currency']);
735 735
 
736 736
         // Abort if the payment is already recorded.
737
-        if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) {
737
+        if (wpinv_get_id_by_transaction_id($posted['txn_id'])) {
738 738
             return;
739 739
         }
740 740
 
741 741
         // Abort if this is the first payment.
742
-        if ( date( 'Ynd', $subscription->created ) == date( 'Ynd', strtotime( $posted['payment_date'] ) ) ) {
743
-            $invoice->set_transaction_id( $posted['txn_id'] );
742
+        if (date('Ynd', $subscription->created) == date('Ynd', strtotime($posted['payment_date']))) {
743
+            $invoice->set_transaction_id($posted['txn_id']);
744 744
             $invoice->save();
745 745
             return;
746 746
         }
@@ -751,14 +751,14 @@  discard block
 block discarded – undo
751 751
             'gateway'        => $this->id,
752 752
         );
753 753
 
754
-        $invoice = wpinv_get_invoice( $subscription->add_payment( $args ) );
754
+        $invoice = wpinv_get_invoice($subscription->add_payment($args));
755 755
 
756
-        if ( empty( $invoice ) ) {
756
+        if (empty($invoice)) {
757 757
             return;
758 758
         }
759 759
 
760
-        $invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true );
761
-        $invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
760
+        $invoice->add_note(wp_sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $posted['txn_id']), false, false, true);
761
+        $invoice->add_note(wp_sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $posted['subscr_id']), false, false, true);
762 762
 
763 763
         $subscription->renew();
764 764
 
@@ -770,9 +770,9 @@  discard block
 block discarded – undo
770 770
 	 * @param WPInv_Invoice $invoice  Invoice object.
771 771
 	 * @param array    $posted Posted data.
772 772
 	 */
773
-	protected function ipn_txn_subscr_cancel( $invoice, $posted ) {
773
+	protected function ipn_txn_subscr_cancel($invoice, $posted) {
774 774
 
775
-        if ( $subscription = wpinv_get_subscription( $invoice ) ) {
775
+        if ($subscription = wpinv_get_subscription($invoice)) {
776 776
             $subscription->cancel();
777 777
         }
778 778
 
@@ -784,9 +784,9 @@  discard block
 block discarded – undo
784 784
 	 * @param WPInv_Invoice $invoice  Invoice object.
785 785
 	 * @param array    $posted Posted data.
786 786
 	 */
787
-	protected function ipn_txn_subscr_eot( $invoice, $posted ) {
787
+	protected function ipn_txn_subscr_eot($invoice, $posted) {
788 788
 
789
-        if ( $subscription = wpinv_get_subscription( $invoice ) ) {
789
+        if ($subscription = wpinv_get_subscription($invoice)) {
790 790
             $subscription->complete();
791 791
         }
792 792
 
@@ -798,9 +798,9 @@  discard block
 block discarded – undo
798 798
 	 * @param WPInv_Invoice $invoice  Invoice object.
799 799
 	 * @param array    $posted Posted data.
800 800
 	 */
801
-	protected function ipn_txn_subscr_failed( $invoice, $posted ) {
801
+	protected function ipn_txn_subscr_failed($invoice, $posted) {
802 802
 
803
-        if ( $subscription = wpinv_get_subscription( $invoice ) ) {
803
+        if ($subscription = wpinv_get_subscription($invoice)) {
804 804
             $subscription->failing();
805 805
         }
806 806
 
@@ -809,10 +809,10 @@  discard block
 block discarded – undo
809 809
     /**
810 810
      * Displays a notice on the checkout page if sandbox is enabled.
811 811
      */
812
-    public function sandbox_notice( $description, $gateway ) {
813
-        if ( 'paypal' == $gateway && wpinv_is_test_mode( 'paypal' ) ) {
812
+    public function sandbox_notice($description, $gateway) {
813
+        if ('paypal' == $gateway && wpinv_is_test_mode('paypal')) {
814 814
             $description .= '<br>' . sprintf(
815
-                __( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing' ),
815
+                __('SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing'),
816 816
                 '<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">',
817 817
                 '</a>'
818 818
             );
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-worldpay-gateway.php 2 patches
Indentation   +94 added lines, -94 removed lines patch added patch discarded remove patch
@@ -13,65 +13,65 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Worldpay_Gateway extends GetPaid_Payment_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'worldpay';
21 21
 
22 22
     /**
23
-	 * Payment method order.
24
-	 *
25
-	 * @var int
26
-	 */
23
+     * Payment method order.
24
+     *
25
+     * @var int
26
+     */
27 27
     public $order = 5;
28 28
 
29 29
     /**
30
-	 * Endpoint for requests from Worldpay.
31
-	 *
32
-	 * @var string
33
-	 */
34
-	protected $notify_url;
35
-
36
-	/**
37
-	 * Endpoint for requests to Worldpay.
38
-	 *
39
-	 * @var string
40
-	 */
30
+     * Endpoint for requests from Worldpay.
31
+     *
32
+     * @var string
33
+     */
34
+    protected $notify_url;
35
+
36
+    /**
37
+     * Endpoint for requests to Worldpay.
38
+     *
39
+     * @var string
40
+     */
41 41
     protected $endpoint;
42 42
 
43 43
     /**
44
-	 * An array of features that this gateway supports.
45
-	 *
46
-	 * @var array
47
-	 */
44
+     * An array of features that this gateway supports.
45
+     *
46
+     * @var array
47
+     */
48 48
     protected $supports = array( 'sandbox' );
49 49
     
50 50
     /**
51
-	 * Currencies this gateway is allowed for.
52
-	 *
53
-	 * @var array
54
-	 */
55
-	public $currencies = array( 'AUD', 'ARS', 'CAD', 'CHF', 'DKK', 'EUR', 'HKD', 'MYR', 'GBP', 'NZD', 'NOK', 'SGD', 'LKR', 'SEK', 'TRY', 'USD', 'ZAR' );
51
+     * Currencies this gateway is allowed for.
52
+     *
53
+     * @var array
54
+     */
55
+    public $currencies = array( 'AUD', 'ARS', 'CAD', 'CHF', 'DKK', 'EUR', 'HKD', 'MYR', 'GBP', 'NZD', 'NOK', 'SGD', 'LKR', 'SEK', 'TRY', 'USD', 'ZAR' );
56 56
 
57 57
     /**
58
-	 * URL to view a transaction.
59
-	 *
60
-	 * @var string
61
-	 */
58
+     * URL to view a transaction.
59
+     *
60
+     * @var string
61
+     */
62 62
     public $view_transaction_url = 'https://www.{sandbox}paypal.com/activity/payment/%s';
63 63
 
64 64
     /**
65
-	 * URL to view a subscription.
66
-	 *
67
-	 * @var string
68
-	 */
69
-	public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s';
65
+     * URL to view a subscription.
66
+     *
67
+     * @var string
68
+     */
69
+    public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s';
70 70
 
71 71
     /**
72
-	 * Class constructor.
73
-	 */
74
-	public function __construct() {
72
+     * Class constructor.
73
+     */
74
+    public function __construct() {
75 75
 
76 76
         $this->method_title      = __( 'Worldpay', 'invoicing' );
77 77
         $this->title             = __( 'Worldpay - Credit Card / Debit Card', 'invoicing' );
@@ -85,15 +85,15 @@  discard block
 block discarded – undo
85 85
     }
86 86
 
87 87
     /**
88
-	 * Process Payment.
89
-	 *
90
-	 *
91
-	 * @param WPInv_Invoice $invoice Invoice.
92
-	 * @param array $submission_data Posted checkout fields.
93
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
94
-	 * @return array
95
-	 */
96
-	public function process_payment( $invoice, $submission_data, $submission ) {
88
+     * Process Payment.
89
+     *
90
+     *
91
+     * @param WPInv_Invoice $invoice Invoice.
92
+     * @param array $submission_data Posted checkout fields.
93
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
94
+     * @return array
95
+     */
96
+    public function process_payment( $invoice, $submission_data, $submission ) {
97 97
 
98 98
         // Get redirect url.
99 99
         $worldpay_redirect = esc_url( $this->get_request_url( $invoice ) );
@@ -128,31 +128,31 @@  discard block
 block discarded – undo
128 128
     }
129 129
 
130 130
     /**
131
-	 * Get the Worldpay request URL for an invoice.
132
-	 *
133
-	 * @param  WPInv_Invoice $invoice Invoice object.
134
-	 * @return string
135
-	 */
136
-	public function get_request_url( $invoice ) {
131
+     * Get the Worldpay request URL for an invoice.
132
+     *
133
+     * @param  WPInv_Invoice $invoice Invoice object.
134
+     * @return string
135
+     */
136
+    public function get_request_url( $invoice ) {
137 137
 
138 138
         // Endpoint for this request
139
-		$this->endpoint = $this->is_sandbox( $invoice ) ? 'https://secure-test.worldpay.com/wcc/purchase' : 'https://secure.worldpay.com/wcc/purchase';
139
+        $this->endpoint = $this->is_sandbox( $invoice ) ? 'https://secure-test.worldpay.com/wcc/purchase' : 'https://secure.worldpay.com/wcc/purchase';
140 140
 
141 141
         return $this->endpoint;
142 142
 
143
-	}
143
+    }
144 144
 
145 145
     /**
146
-	 * Get Worldpay Args for passing to Worldpay.
147
-	 *
148
-	 * @param  WPInv_Invoice $invoice Invoice object.
149
-	 * @return array
150
-	 */
151
-	protected function get_worldpay_args( $invoice ) {
152
-
153
-		return apply_filters(
154
-			'getpaid_worldpay_args',
155
-			array(
146
+     * Get Worldpay Args for passing to Worldpay.
147
+     *
148
+     * @param  WPInv_Invoice $invoice Invoice object.
149
+     * @return array
150
+     */
151
+    protected function get_worldpay_args( $invoice ) {
152
+
153
+        return apply_filters(
154
+            'getpaid_worldpay_args',
155
+            array(
156 156
                 'amount'         => wpinv_sanitize_amount( $invoice->get_total() ), // mandatory
157 157
                 'cartId'         => wpinv_clean( $invoice->get_number() ), // mandatory reference for the item purchased
158 158
                 'currency'       => wpinv_clean( $invoice->get_currency() ), // mandatory
@@ -177,18 +177,18 @@  discard block
 block discarded – undo
177 177
                 'countryString'  => wpinv_clean( wpinv_country_name( $invoice->get_country() ) ),
178 178
                 'compName'       => wpinv_clean( $invoice->get_company() ),
179 179
             ),
180
-			$invoice
181
-		);
180
+            $invoice
181
+        );
182 182
 
183 183
     }
184 184
 
185 185
     /**
186
-	 * Secures worldpay args with an md5 hash.
187
-	 *
188
-	 * @param  array $args Gateway args.
189
-	 * @return array
190
-	 */
191
-	public function hash_args( $args ) {
186
+     * Secures worldpay args with an md5 hash.
187
+     *
188
+     * @param  array $args Gateway args.
189
+     * @return array
190
+     */
191
+    public function hash_args( $args ) {
192 192
 
193 193
         $md5_secret = $this->get_option( 'md5_secret' );
194 194
 
@@ -204,16 +204,16 @@  discard block
 block discarded – undo
204 204
     }
205 205
 
206 206
     /**
207
-	 * Processes ipns and marks payments as complete.
208
-	 *
209
-	 * @return void
210
-	 */
211
-	public function verify_ipn() {
207
+     * Processes ipns and marks payments as complete.
208
+     *
209
+     * @return void
210
+     */
211
+    public function verify_ipn() {
212 212
 
213 213
         // Validate the IPN.
214 214
         if ( empty( $_POST ) || ! $this->validate_ipn() ) {
215
-		    wp_die( 'Worldpay IPN Request Failure', 'Worldpay IPN', array( 'response' => 500 ) );
216
-		}
215
+            wp_die( 'Worldpay IPN Request Failure', 'Worldpay IPN', array( 'response' => 500 ) );
216
+        }
217 217
 
218 218
         // Process the IPN.
219 219
         $posted  = wp_unslash( $_POST );
@@ -229,8 +229,8 @@  discard block
 block discarded – undo
229 229
                 $invoice->set_transaction_id( wpinv_clean( $posted['transId'] ) );
230 230
             }
231 231
 
232
-             // Update the ip address.
233
-             if ( ! empty( $posted['ipAddress'] ) ) {
232
+                // Update the ip address.
233
+                if ( ! empty( $posted['ipAddress'] ) ) {
234 234
                 $invoice->set_ip( wpinv_clean( $posted['ipAddress'] ) );
235 235
             }
236 236
 
@@ -257,9 +257,9 @@  discard block
 block discarded – undo
257 257
     }
258 258
 
259 259
     /**
260
-	 * Check Worldpay IPN validity.
261
-	 */
262
-	public function validate_ipn() {
260
+     * Check Worldpay IPN validity.
261
+     */
262
+    public function validate_ipn() {
263 263
 
264 264
         wpinv_error_log( 'Validating Worldpay IPN response' );
265 265
 
@@ -305,11 +305,11 @@  discard block
 block discarded – undo
305 305
     }
306 306
 
307 307
     /**
308
-	 * Filters the gateway settings.
309
-	 * 
310
-	 * @param array $admin_settings
311
-	 */
312
-	public function admin_settings( $admin_settings ) {
308
+     * Filters the gateway settings.
309
+     * 
310
+     * @param array $admin_settings
311
+     */
312
+    public function admin_settings( $admin_settings ) {
313 313
 
314 314
         $currencies = sprintf(
315 315
             __( 'Supported Currencies: %s', 'invoicing' ),
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
             'readonly' => true
351 351
         );
352 352
 
353
-		return $admin_settings;
354
-	}
353
+        return $admin_settings;
354
+    }
355 355
 
356 356
 }
Please login to merge, or discard this patch.
Spacing   +86 added lines, -86 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
  * Worldpay Payment Gateway class.
@@ -45,14 +45,14 @@  discard block
 block discarded – undo
45 45
 	 *
46 46
 	 * @var array
47 47
 	 */
48
-    protected $supports = array( 'sandbox' );
48
+    protected $supports = array('sandbox');
49 49
     
50 50
     /**
51 51
 	 * Currencies this gateway is allowed for.
52 52
 	 *
53 53
 	 * @var array
54 54
 	 */
55
-	public $currencies = array( 'AUD', 'ARS', 'CAD', 'CHF', 'DKK', 'EUR', 'HKD', 'MYR', 'GBP', 'NZD', 'NOK', 'SGD', 'LKR', 'SEK', 'TRY', 'USD', 'ZAR' );
55
+	public $currencies = array('AUD', 'ARS', 'CAD', 'CHF', 'DKK', 'EUR', 'HKD', 'MYR', 'GBP', 'NZD', 'NOK', 'SGD', 'LKR', 'SEK', 'TRY', 'USD', 'ZAR');
56 56
 
57 57
     /**
58 58
 	 * URL to view a transaction.
@@ -73,13 +73,13 @@  discard block
 block discarded – undo
73 73
 	 */
74 74
 	public function __construct() {
75 75
 
76
-        $this->method_title      = __( 'Worldpay', 'invoicing' );
77
-        $this->title             = __( 'Worldpay - Credit Card / Debit Card', 'invoicing' );
78
-        $this->order_button_text = __( 'Proceed to Worldpay', 'invoicing' );
79
-        $this->notify_url        = wpinv_get_ipn_url( $this->id );
76
+        $this->method_title      = __('Worldpay', 'invoicing');
77
+        $this->title             = __('Worldpay - Credit Card / Debit Card', 'invoicing');
78
+        $this->order_button_text = __('Proceed to Worldpay', 'invoicing');
79
+        $this->notify_url        = wpinv_get_ipn_url($this->id);
80 80
 
81
-        add_filter( 'wpinv_gateway_description', array( $this, 'sandbox_notice' ), 10, 2 );
82
-        add_filter( 'getpaid_worldpay_args', array( $this, 'hash_args' ) );
81
+        add_filter('wpinv_gateway_description', array($this, 'sandbox_notice'), 10, 2);
82
+        add_filter('getpaid_worldpay_args', array($this, 'hash_args'));
83 83
 
84 84
         parent::__construct();
85 85
     }
@@ -93,24 +93,24 @@  discard block
 block discarded – undo
93 93
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
94 94
 	 * @return array
95 95
 	 */
96
-	public function process_payment( $invoice, $submission_data, $submission ) {
96
+	public function process_payment($invoice, $submission_data, $submission) {
97 97
 
98 98
         // Get redirect url.
99
-        $worldpay_redirect = esc_url( $this->get_request_url( $invoice ) );
99
+        $worldpay_redirect = esc_url($this->get_request_url($invoice));
100 100
 
101 101
         // Get submission args.
102
-        $worldpay_args     = $this->get_worldpay_args( $invoice );
102
+        $worldpay_args     = $this->get_worldpay_args($invoice);
103 103
 
104 104
         $form = "<form action='$worldpay_redirect' name='wpi_worldpay_form' method='POST'>";
105 105
 
106
-        foreach ( $worldpay_args as $key => $value ) {
106
+        foreach ($worldpay_args as $key => $value) {
107 107
 
108
-            if ( false === $value || '' === trim( $value ) ) {
108
+            if (false === $value || '' === trim($value)) {
109 109
                 continue;
110 110
             }
111 111
 
112
-            $value = esc_attr( $value );
113
-            $key   = wpinv_clean( $key );
112
+            $value = esc_attr($value);
113
+            $key   = wpinv_clean($key);
114 114
             $form .= "<input type='hidden' name='$key' value='$value'>";
115 115
         }
116 116
 
@@ -133,10 +133,10 @@  discard block
 block discarded – undo
133 133
 	 * @param  WPInv_Invoice $invoice Invoice object.
134 134
 	 * @return string
135 135
 	 */
136
-	public function get_request_url( $invoice ) {
136
+	public function get_request_url($invoice) {
137 137
 
138 138
         // Endpoint for this request
139
-		$this->endpoint = $this->is_sandbox( $invoice ) ? 'https://secure-test.worldpay.com/wcc/purchase' : 'https://secure.worldpay.com/wcc/purchase';
139
+		$this->endpoint = $this->is_sandbox($invoice) ? 'https://secure-test.worldpay.com/wcc/purchase' : 'https://secure.worldpay.com/wcc/purchase';
140 140
 
141 141
         return $this->endpoint;
142 142
 
@@ -148,34 +148,34 @@  discard block
 block discarded – undo
148 148
 	 * @param  WPInv_Invoice $invoice Invoice object.
149 149
 	 * @return array
150 150
 	 */
151
-	protected function get_worldpay_args( $invoice ) {
151
+	protected function get_worldpay_args($invoice) {
152 152
 
153 153
 		return apply_filters(
154 154
 			'getpaid_worldpay_args',
155 155
 			array(
156
-                'amount'         => wpinv_sanitize_amount( $invoice->get_total() ), // mandatory
157
-                'cartId'         => wpinv_clean( $invoice->get_number() ), // mandatory reference for the item purchased
158
-                'currency'       => wpinv_clean( $invoice->get_currency() ), // mandatory
159
-                'instId'         => wpinv_clean( $this->get_option( 'instId', '' ) ), // mandatory
160
-                'testMode'       => $this->is_sandbox( $invoice ) ? 100 : 0, // mandatory
161
-                'name'           => wpinv_clean( $invoice->get_full_name() ),
162
-                'address'        => wpinv_clean( $invoice->get_address() ),
163
-                'postcode'       => wpinv_clean( $invoice->get_zip() ),
164
-                'tel'            => wpinv_clean( $invoice->get_phone() ),
165
-                'email'          => sanitize_email( $invoice->get_email() ),
166
-                'country'        => wpinv_clean( $invoice->get_country() ),
167
-                'desc'           => sprintf( __( 'Payment for invoice %s.', 'invoicing' ), wpinv_clean( $invoice->get_number() ) ),
168
-                'MC_description' => sprintf( __( 'Payment for invoice %s.', 'invoicing' ), wpinv_clean( $invoice->get_number() ) ),
169
-                'MC_callback'    => esc_url_raw( $this->notify_url ),
170
-                'resultfile'     => esc_url_raw( $this->get_return_url( $invoice ) ),
171
-                'MC_key'         => wpinv_clean( $invoice->get_key() ),
156
+                'amount'         => wpinv_sanitize_amount($invoice->get_total()), // mandatory
157
+                'cartId'         => wpinv_clean($invoice->get_number()), // mandatory reference for the item purchased
158
+                'currency'       => wpinv_clean($invoice->get_currency()), // mandatory
159
+                'instId'         => wpinv_clean($this->get_option('instId', '')), // mandatory
160
+                'testMode'       => $this->is_sandbox($invoice) ? 100 : 0, // mandatory
161
+                'name'           => wpinv_clean($invoice->get_full_name()),
162
+                'address'        => wpinv_clean($invoice->get_address()),
163
+                'postcode'       => wpinv_clean($invoice->get_zip()),
164
+                'tel'            => wpinv_clean($invoice->get_phone()),
165
+                'email'          => sanitize_email($invoice->get_email()),
166
+                'country'        => wpinv_clean($invoice->get_country()),
167
+                'desc'           => sprintf(__('Payment for invoice %s.', 'invoicing'), wpinv_clean($invoice->get_number())),
168
+                'MC_description' => sprintf(__('Payment for invoice %s.', 'invoicing'), wpinv_clean($invoice->get_number())),
169
+                'MC_callback'    => esc_url_raw($this->notify_url),
170
+                'resultfile'     => esc_url_raw($this->get_return_url($invoice)),
171
+                'MC_key'         => wpinv_clean($invoice->get_key()),
172 172
                 'MC_invoice_id'  => $invoice->get_id(),
173
-                'address1'       => wpinv_clean( $invoice->get_address() ),
174
-                'town'           => wpinv_clean( $invoice->get_city() ),
175
-                'region'         => wpinv_clean( $invoice->get_state() ),
176
-                'amountString'   => wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ),
177
-                'countryString'  => wpinv_clean( wpinv_country_name( $invoice->get_country() ) ),
178
-                'compName'       => wpinv_clean( $invoice->get_company() ),
173
+                'address1'       => wpinv_clean($invoice->get_address()),
174
+                'town'           => wpinv_clean($invoice->get_city()),
175
+                'region'         => wpinv_clean($invoice->get_state()),
176
+                'amountString'   => wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()),
177
+                'countryString'  => wpinv_clean(wpinv_country_name($invoice->get_country())),
178
+                'compName'       => wpinv_clean($invoice->get_company()),
179 179
             ),
180 180
 			$invoice
181 181
 		);
@@ -188,17 +188,17 @@  discard block
 block discarded – undo
188 188
 	 * @param  array $args Gateway args.
189 189
 	 * @return array
190 190
 	 */
191
-	public function hash_args( $args ) {
191
+	public function hash_args($args) {
192 192
 
193
-        $md5_secret = $this->get_option( 'md5_secret' );
193
+        $md5_secret = $this->get_option('md5_secret');
194 194
 
195 195
         // Abort if there is no secret.
196
-        if ( empty( $md5_secret ) ) {
196
+        if (empty($md5_secret)) {
197 197
             return $args;
198 198
         }
199 199
 
200 200
         // Hash the args.
201
-        $args['signature'] = md5( "$md5_secret:{$args['instId']}:{$args['amount']}:{$args['currency']}:{$args['cartId']}" );
201
+        $args['signature'] = md5("$md5_secret:{$args['instId']}:{$args['amount']}:{$args['currency']}:{$args['cartId']}");
202 202
 
203 203
         return $args;
204 204
     }
@@ -211,43 +211,43 @@  discard block
 block discarded – undo
211 211
 	public function verify_ipn() {
212 212
 
213 213
         // Validate the IPN.
214
-        if ( empty( $_POST ) || ! $this->validate_ipn() ) {
215
-		    wp_die( 'Worldpay IPN Request Failure', 'Worldpay IPN', array( 'response' => 500 ) );
214
+        if (empty($_POST) || !$this->validate_ipn()) {
215
+		    wp_die('Worldpay IPN Request Failure', 'Worldpay IPN', array('response' => 500));
216 216
 		}
217 217
 
218 218
         // Process the IPN.
219
-        $posted  = wp_unslash( $_POST );
220
-        $invoice = wpinv_get_invoice( $posted['MC_invoice_id'] );
219
+        $posted  = wp_unslash($_POST);
220
+        $invoice = wpinv_get_invoice($posted['MC_invoice_id']);
221 221
 
222
-        if ( $invoice && $this->id == $invoice->get_gateway() ) {
222
+        if ($invoice && $this->id == $invoice->get_gateway()) {
223 223
 
224
-            wpinv_error_log( 'Found invoice #' . $invoice->get_number() );
225
-            wpinv_error_log( 'Payment status:' . $posted['transStatus'] );
224
+            wpinv_error_log('Found invoice #' . $invoice->get_number());
225
+            wpinv_error_log('Payment status:' . $posted['transStatus']);
226 226
 
227 227
             // Update the transaction id.
228
-            if ( ! empty( $posted['transId'] ) ) {
229
-                $invoice->set_transaction_id( wpinv_clean( $posted['transId'] ) );
228
+            if (!empty($posted['transId'])) {
229
+                $invoice->set_transaction_id(wpinv_clean($posted['transId']));
230 230
             }
231 231
 
232 232
              // Update the ip address.
233
-             if ( ! empty( $posted['ipAddress'] ) ) {
234
-                $invoice->set_ip( wpinv_clean( $posted['ipAddress'] ) );
233
+             if (!empty($posted['ipAddress'])) {
234
+                $invoice->set_ip(wpinv_clean($posted['ipAddress']));
235 235
             }
236 236
 
237
-            if ( $posted['transStatus'] == 'Y' ) {
238
-                $invoice->set_completed_date( date( 'Y-m-d H:i:s', $posted['transTime'] ) );
237
+            if ($posted['transStatus'] == 'Y') {
238
+                $invoice->set_completed_date(date('Y-m-d H:i:s', $posted['transTime']));
239 239
                 $invoice->mark_paid();
240 240
                 return;
241 241
             }
242 242
 
243
-            if ( $posted['transStatus'] == 'C' ) {
244
-                $invoice->set_status( 'wpi-failed' );
245
-                $invoice->add_note( __( 'Payment transaction failed while processing Worldpay payment.', 'invoicing' ), false, false, true );
243
+            if ($posted['transStatus'] == 'C') {
244
+                $invoice->set_status('wpi-failed');
245
+                $invoice->add_note(__('Payment transaction failed while processing Worldpay payment.', 'invoicing'), false, false, true);
246 246
                 $invoice->save();
247 247
                 return;
248 248
             }
249 249
 
250
-            wpinv_error_log( 'Aborting, Invalid transaction status:' . $posted['transStatus'] );
250
+            wpinv_error_log('Aborting, Invalid transaction status:' . $posted['transStatus']);
251 251
             $invoice->save();
252 252
 
253 253
         }
@@ -261,27 +261,27 @@  discard block
 block discarded – undo
261 261
 	 */
262 262
 	public function validate_ipn() {
263 263
 
264
-        wpinv_error_log( 'Validating Worldpay IPN response' );
264
+        wpinv_error_log('Validating Worldpay IPN response');
265 265
 
266
-        $data = wp_unslash( $_POST );
266
+        $data = wp_unslash($_POST);
267 267
 
268 268
         // Verify installation.
269
-        if ( empty( $data['instId'] ) || $data['instId'] != wpinv_clean( $this->get_option( 'instId', '' ) ) ) {
270
-            wpinv_error_log( 'Received invalid installation ID from Worldpay IPN' );
269
+        if (empty($data['instId']) || $data['instId'] != wpinv_clean($this->get_option('instId', ''))) {
270
+            wpinv_error_log('Received invalid installation ID from Worldpay IPN');
271 271
             return false;
272 272
         }
273 273
 
274 274
         // Verify invoice.
275
-        if ( empty( $data['cartId'] ) || !  wpinv_get_id_by_invoice_number( $data['cartId'] ) ) {
276
-            wpinv_error_log( 'Received invalid invoice number from Worldpay IPN' );
275
+        if (empty($data['cartId']) || !wpinv_get_id_by_invoice_number($data['cartId'])) {
276
+            wpinv_error_log('Received invalid invoice number from Worldpay IPN');
277 277
             return false;
278 278
         }
279 279
         
280 280
         // (maybe) verify password.
281
-        $password = $this->get_option( 'callback_password' );
281
+        $password = $this->get_option('callback_password');
282 282
 
283
-        if ( ! empty( $password ) && ( empty( $data['callbackPW'] ) || $password != $data['callbackPW'] ) ) {
284
-            wpinv_error_log( 'Received invalid invoice number from Worldpay IPN' );
283
+        if (!empty($password) && (empty($data['callbackPW']) || $password != $data['callbackPW'])) {
284
+            wpinv_error_log('Received invalid invoice number from Worldpay IPN');
285 285
             return false;
286 286
         }
287 287
 
@@ -292,10 +292,10 @@  discard block
 block discarded – undo
292 292
     /**
293 293
      * Displays a notice on the checkout page if sandbox is enabled.
294 294
      */
295
-    public function sandbox_notice( $description, $gateway ) {
296
-        if ( 'worldpay' == $gateway && wpinv_is_test_mode( 'worldpay' ) ) {
295
+    public function sandbox_notice($description, $gateway) {
296
+        if ('worldpay' == $gateway && wpinv_is_test_mode('worldpay')) {
297 297
             $description .= '<br>' . sprintf(
298
-                __( 'SANDBOX ENABLED. See the %sWorldpay Sandbox Testing Guide%s for more details.', 'invoicing' ),
298
+                __('SANDBOX ENABLED. See the %sWorldpay Sandbox Testing Guide%s for more details.', 'invoicing'),
299 299
                 '<a href="https://developer.worldpay.com/docs/wpg/directintegration/abouttesting">',
300 300
                 '</a>'
301 301
             );
@@ -309,43 +309,43 @@  discard block
 block discarded – undo
309 309
 	 * 
310 310
 	 * @param array $admin_settings
311 311
 	 */
312
-	public function admin_settings( $admin_settings ) {
312
+	public function admin_settings($admin_settings) {
313 313
 
314 314
         $currencies = sprintf(
315
-            __( 'Supported Currencies: %s', 'invoicing' ),
316
-            implode( ', ', $this->currencies )
315
+            __('Supported Currencies: %s', 'invoicing'),
316
+            implode(', ', $this->currencies)
317 317
         );
318 318
 
319 319
         $admin_settings['worldpay_active']['desc'] = $admin_settings['worldpay_active']['desc'] . " ($currencies)";
320
-        $admin_settings['worldpay_desc']['std']    = __( 'Pay securely via Worldpay using your PayPal account, credit or debit card.', 'invoicing' );
320
+        $admin_settings['worldpay_desc']['std']    = __('Pay securely via Worldpay using your PayPal account, credit or debit card.', 'invoicing');
321 321
 
322 322
         $admin_settings['worldpay_instId'] = array(
323 323
             'type' => 'text',
324 324
             'id'   => 'worldpay_instId',
325
-            'name' => __( 'Installation Id', 'invoicing' ),
326
-            'desc' => __( 'Your installation id. Ex: 211616', 'invoicing' ),
325
+            'name' => __('Installation Id', 'invoicing'),
326
+            'desc' => __('Your installation id. Ex: 211616', 'invoicing'),
327 327
         );
328 328
 
329 329
         $admin_settings['worldpay_md5_secret'] = array(
330 330
             'type' => 'text',
331 331
             'id'   => 'worldpay_md5_secret',
332
-            'name' => __( 'MD5 secret', 'invoicing' ),
333
-            'desc' => __( 'Optionally enter your MD5 secret here. Next, open your installation settings and ensure that your SignatureFields parameter is set to ', 'invoicing' ) . '<code>instId:amount:currency:cartId</code>',
332
+            'name' => __('MD5 secret', 'invoicing'),
333
+            'desc' => __('Optionally enter your MD5 secret here. Next, open your installation settings and ensure that your SignatureFields parameter is set to ', 'invoicing') . '<code>instId:amount:currency:cartId</code>',
334 334
         );
335 335
 
336 336
         $admin_settings['worldpay_callbackPW'] = array(
337 337
             'type' => 'text',
338 338
             'id'   => 'worldpay_callbackPW',
339
-            'name' => __( 'Payment Response password', 'invoicing' ),
340
-            'desc' => __( 'Recommended. Enter your WorldPay response password to validate payment notifications.', 'invoicing' ),
339
+            'name' => __('Payment Response password', 'invoicing'),
340
+            'desc' => __('Recommended. Enter your WorldPay response password to validate payment notifications.', 'invoicing'),
341 341
         );
342 342
 
343 343
         $admin_settings['worldpay_ipn_url'] = array(
344 344
             'type'     => 'ipn_url',
345 345
             'id'       => 'worldpay_ipn_url',
346
-            'name'     => __( 'Payment Response URL', 'invoicing' ),
346
+            'name'     => __('Payment Response URL', 'invoicing'),
347 347
             'std'      => $this->notify_url,
348
-            'desc'     => __( 'Login to your Worldpay Merchant Interface then enable Payment Response & Shopper Response. Next, go to the Payment Response URL field and enter the above URL.', 'invoicing' ),
348
+            'desc'     => __('Login to your Worldpay Merchant Interface then enable Payment Response & Shopper Response. Next, go to the Payment Response URL field and enter the above URL.', 'invoicing'),
349 349
             'custom'   => 'worldpay',
350 350
             'readonly' => true
351 351
         );
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-payment-gateway.php 2 patches
Indentation   +530 added lines, -530 removed lines patch added patch discarded remove patch
@@ -13,566 +13,566 @@
 block discarded – undo
13 13
  */
14 14
 abstract class GetPaid_Payment_Gateway {
15 15
 
16
-	/**
17
-	 * Set if the place checkout button should be renamed on selection.
18
-	 *
19
-	 * @var string
20
-	 */
21
-	public $checkout_button_text;
22
-
23
-	/**
24
-	 * Boolean whether the method is enabled.
25
-	 *
26
-	 * @var bool
27
-	 */
28
-	public $enabled = true;
29
-
30
-	/**
31
-	 * Payment method id.
32
-	 *
33
-	 * @var string
34
-	 */
35
-	public $id;
36
-
37
-	/**
38
-	 * Payment method order.
39
-	 *
40
-	 * @var int
41
-	 */
42
-	public $order = 10;
43
-
44
-	/**
45
-	 * Payment method title for the frontend.
46
-	 *
47
-	 * @var string
48
-	 */
49
-	public $title;
50
-
51
-	/**
52
-	 * Payment method description for the frontend.
53
-	 *
54
-	 * @var string
55
-	 */
56
-	public $description;
57
-
58
-	/**
59
-	 * Gateway title.
60
-	 *
61
-	 * @var string
62
-	 */
63
-	public $method_title = '';
64
-
65
-	/**
66
-	 * Gateway description.
67
-	 *
68
-	 * @var string
69
-	 */
70
-	public $method_description = '';
71
-
72
-	/**
73
-	 * Countries this gateway is allowed for.
74
-	 *
75
-	 * @var array
76
-	 */
77
-	public $countries;
78
-
79
-	/**
80
-	 * Currencies this gateway is allowed for.
81
-	 *
82
-	 * @var array
83
-	 */
84
-	public $currencies;
85
-
86
-	/**
87
-	 * Currencies this gateway is not allowed for.
88
-	 *
89
-	 * @var array
90
-	 */
91
-	public $exclude_currencies;
92
-
93
-	/**
94
-	 * Maximum transaction amount, zero does not define a maximum.
95
-	 *
96
-	 * @var int
97
-	 */
98
-	public $max_amount = 0;
99
-
100
-	/**
101
-	 * Optional URL to view a transaction.
102
-	 *
103
-	 * @var string
104
-	 */
105
-	public $view_transaction_url = '';
106
-
107
-	/**
108
-	 * Optional URL to view a subscription.
109
-	 *
110
-	 * @var string
111
-	 */
112
-	public $view_subscription_url = '';
113
-
114
-	/**
115
-	 * Optional label to show for "new payment method" in the payment
116
-	 * method/token selection radio selection.
117
-	 *
118
-	 * @var string
119
-	 */
120
-	public $new_method_label = '';
121
-
122
-	/**
123
-	 * Contains a users saved tokens for this gateway.
124
-	 *
125
-	 * @var array
126
-	 */
127
-	protected $tokens = array();
128
-
129
-	/**
130
-	 * An array of features that this gateway supports.
131
-	 *
132
-	 * @var array
133
-	 */
134
-	protected $supports = array();
135
-
136
-	/**
137
-	 * Class constructor.
138
-	 */
139
-	public function __construct() {
140
-		$this->enabled = wpinv_is_gateway_active( $this->id );
141
-
142
-		// Register gateway.
143
-		add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) );
144
-
145
-		// Enable Subscriptions.
146
-		if ( $this->supports( 'subscription' ) ) {
147
-			add_filter( "wpinv_{$this->id}_support_subscription", '__return_true' );
148
-		}
149
-
150
-		// Enable sandbox.
151
-		if ( $this->supports( 'sandbox' ) ) {
152
-			add_filter( "wpinv_{$this->id}_supports_sandbox", '__return_true' );
153
-		}
154
-
155
-		// Gateway settings.
156
-		add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) );
16
+    /**
17
+     * Set if the place checkout button should be renamed on selection.
18
+     *
19
+     * @var string
20
+     */
21
+    public $checkout_button_text;
22
+
23
+    /**
24
+     * Boolean whether the method is enabled.
25
+     *
26
+     * @var bool
27
+     */
28
+    public $enabled = true;
29
+
30
+    /**
31
+     * Payment method id.
32
+     *
33
+     * @var string
34
+     */
35
+    public $id;
36
+
37
+    /**
38
+     * Payment method order.
39
+     *
40
+     * @var int
41
+     */
42
+    public $order = 10;
43
+
44
+    /**
45
+     * Payment method title for the frontend.
46
+     *
47
+     * @var string
48
+     */
49
+    public $title;
50
+
51
+    /**
52
+     * Payment method description for the frontend.
53
+     *
54
+     * @var string
55
+     */
56
+    public $description;
57
+
58
+    /**
59
+     * Gateway title.
60
+     *
61
+     * @var string
62
+     */
63
+    public $method_title = '';
64
+
65
+    /**
66
+     * Gateway description.
67
+     *
68
+     * @var string
69
+     */
70
+    public $method_description = '';
71
+
72
+    /**
73
+     * Countries this gateway is allowed for.
74
+     *
75
+     * @var array
76
+     */
77
+    public $countries;
78
+
79
+    /**
80
+     * Currencies this gateway is allowed for.
81
+     *
82
+     * @var array
83
+     */
84
+    public $currencies;
85
+
86
+    /**
87
+     * Currencies this gateway is not allowed for.
88
+     *
89
+     * @var array
90
+     */
91
+    public $exclude_currencies;
92
+
93
+    /**
94
+     * Maximum transaction amount, zero does not define a maximum.
95
+     *
96
+     * @var int
97
+     */
98
+    public $max_amount = 0;
99
+
100
+    /**
101
+     * Optional URL to view a transaction.
102
+     *
103
+     * @var string
104
+     */
105
+    public $view_transaction_url = '';
106
+
107
+    /**
108
+     * Optional URL to view a subscription.
109
+     *
110
+     * @var string
111
+     */
112
+    public $view_subscription_url = '';
113
+
114
+    /**
115
+     * Optional label to show for "new payment method" in the payment
116
+     * method/token selection radio selection.
117
+     *
118
+     * @var string
119
+     */
120
+    public $new_method_label = '';
121
+
122
+    /**
123
+     * Contains a users saved tokens for this gateway.
124
+     *
125
+     * @var array
126
+     */
127
+    protected $tokens = array();
128
+
129
+    /**
130
+     * An array of features that this gateway supports.
131
+     *
132
+     * @var array
133
+     */
134
+    protected $supports = array();
135
+
136
+    /**
137
+     * Class constructor.
138
+     */
139
+    public function __construct() {
140
+        $this->enabled = wpinv_is_gateway_active( $this->id );
141
+
142
+        // Register gateway.
143
+        add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) );
144
+
145
+        // Enable Subscriptions.
146
+        if ( $this->supports( 'subscription' ) ) {
147
+            add_filter( "wpinv_{$this->id}_support_subscription", '__return_true' );
148
+        }
149
+
150
+        // Enable sandbox.
151
+        if ( $this->supports( 'sandbox' ) ) {
152
+            add_filter( "wpinv_{$this->id}_supports_sandbox", '__return_true' );
153
+        }
154
+
155
+        // Gateway settings.
156
+        add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) );
157 157
 		
158 158
 
159
-		// Gateway checkout fiellds.
160
-		add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 );
161
-
162
-		// Process payment.
163
-		add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 );
164
-
165
-		// Change the checkout button text.
166
-		if ( ! empty( $this->checkout_button_text ) ) {
167
-			add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) );
168
-		}
169
-
170
-		// Check if a gateway is valid for a given currency.
171
-		add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 );
172
-
173
-		// Generate the transaction url.
174
-		add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 );
175
-
176
-		// Generate the subscription url.
177
-		add_filter( "getpaid_gateway_{$this->id}_subscription_url", array( $this, 'filter_subscription_url' ), 10, 2 );
178
-
179
-		// Confirm payments.
180
-		add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 );
181
-
182
-		// Verify IPNs.
183
-		add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) );
184
-
185
-	}
186
-
187
-	/**
188
-	 * Checks if this gateway is a given gateway.
189
-	 *
190
-	 * @since 1.0.19
191
-	 * @return bool
192
-	 */
193
-	public function is( $gateway ) {
194
-		return $gateway == $this->id;
195
-	}
196
-
197
-	/**
198
-	 * Returns a users saved tokens for this gateway.
199
-	 *
200
-	 * @since 1.0.19
201
-	 * @return array
202
-	 */
203
-	public function get_tokens() {
204
-
205
-		if ( count( $this->tokens ) > 0 ) {
206
-			return $this->tokens;
207
-		}
208
-
209
-		if ( is_user_logged_in() && $this->supports( 'tokens' ) ) {
210
-			$tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true );
211
-
212
-			if ( is_array( $tokens ) ) {
213
-				$this->tokens = $tokens;
214
-			}
215
-
216
-		}
217
-
218
-		return $this->tokens;
219
-	}
220
-
221
-	/**
222
-	 * Return the title for admin screens.
223
-	 *
224
-	 * @return string
225
-	 */
226
-	public function get_method_title() {
227
-		return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this );
228
-	}
229
-
230
-	/**
231
-	 * Return the description for admin screens.
232
-	 *
233
-	 * @return string
234
-	 */
235
-	public function get_method_description() {
236
-		return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this );
237
-	}
238
-
239
-	/**
240
-	 * Get the success url.
241
-	 *
242
-	 * @param WPInv_Invoice $invoice Invoice object.
243
-	 * @return string
244
-	 */
245
-	public function get_return_url( $invoice ) {
246
-
247
-		// Payment success url
248
-		$return_url = add_query_arg(
249
-			array(
250
-				'payment-confirm' => $this->id,
251
-				'invoice_key'     => $invoice->get_key(),
252
-				'utm_nooverride'  => 1
253
-			),
254
-			wpinv_get_success_page_uri()
255
-		);
256
-
257
-		return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this );
258
-	}
259
-
260
-	/**
261
-	 * Confirms payments when rendering the success page.
262
-	 *
263
-	 * @param string $content Success page content.
264
-	 * @return string
265
-	 */
266
-	public function get_confirm_payment( $content ) {
159
+        // Gateway checkout fiellds.
160
+        add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 );
161
+
162
+        // Process payment.
163
+        add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 );
164
+
165
+        // Change the checkout button text.
166
+        if ( ! empty( $this->checkout_button_text ) ) {
167
+            add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) );
168
+        }
169
+
170
+        // Check if a gateway is valid for a given currency.
171
+        add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 );
172
+
173
+        // Generate the transaction url.
174
+        add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 );
175
+
176
+        // Generate the subscription url.
177
+        add_filter( "getpaid_gateway_{$this->id}_subscription_url", array( $this, 'filter_subscription_url' ), 10, 2 );
178
+
179
+        // Confirm payments.
180
+        add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 );
181
+
182
+        // Verify IPNs.
183
+        add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) );
184
+
185
+    }
186
+
187
+    /**
188
+     * Checks if this gateway is a given gateway.
189
+     *
190
+     * @since 1.0.19
191
+     * @return bool
192
+     */
193
+    public function is( $gateway ) {
194
+        return $gateway == $this->id;
195
+    }
196
+
197
+    /**
198
+     * Returns a users saved tokens for this gateway.
199
+     *
200
+     * @since 1.0.19
201
+     * @return array
202
+     */
203
+    public function get_tokens() {
204
+
205
+        if ( count( $this->tokens ) > 0 ) {
206
+            return $this->tokens;
207
+        }
208
+
209
+        if ( is_user_logged_in() && $this->supports( 'tokens' ) ) {
210
+            $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true );
211
+
212
+            if ( is_array( $tokens ) ) {
213
+                $this->tokens = $tokens;
214
+            }
215
+
216
+        }
217
+
218
+        return $this->tokens;
219
+    }
220
+
221
+    /**
222
+     * Return the title for admin screens.
223
+     *
224
+     * @return string
225
+     */
226
+    public function get_method_title() {
227
+        return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this );
228
+    }
229
+
230
+    /**
231
+     * Return the description for admin screens.
232
+     *
233
+     * @return string
234
+     */
235
+    public function get_method_description() {
236
+        return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this );
237
+    }
238
+
239
+    /**
240
+     * Get the success url.
241
+     *
242
+     * @param WPInv_Invoice $invoice Invoice object.
243
+     * @return string
244
+     */
245
+    public function get_return_url( $invoice ) {
246
+
247
+        // Payment success url
248
+        $return_url = add_query_arg(
249
+            array(
250
+                'payment-confirm' => $this->id,
251
+                'invoice_key'     => $invoice->get_key(),
252
+                'utm_nooverride'  => 1
253
+            ),
254
+            wpinv_get_success_page_uri()
255
+        );
256
+
257
+        return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this );
258
+    }
259
+
260
+    /**
261
+     * Confirms payments when rendering the success page.
262
+     *
263
+     * @param string $content Success page content.
264
+     * @return string
265
+     */
266
+    public function get_confirm_payment( $content ) {
267 267
 		
268
-		// Retrieve the invoice.
269
-		$invoice_id = getpaid_get_current_invoice_id();
270
-		$invoice    = wpinv_get_invoice( $invoice_id );
268
+        // Retrieve the invoice.
269
+        $invoice_id = getpaid_get_current_invoice_id();
270
+        $invoice    = wpinv_get_invoice( $invoice_id );
271 271
 	
272
-		// Ensure that it exists and that it is pending payment.
273
-		if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) {
274
-			return $content;
275
-		}
272
+        // Ensure that it exists and that it is pending payment.
273
+        if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) {
274
+            return $content;
275
+        }
276 276
 	
277
-		// Can the user view this invoice??
278
-		if ( ! wpinv_user_can_view_invoice( $invoice ) ) {
279
-			return $content;
280
-		}
277
+        // Can the user view this invoice??
278
+        if ( ! wpinv_user_can_view_invoice( $invoice ) ) {
279
+            return $content;
280
+        }
281 281
 	
282
-		// Show payment processing indicator.
283
-		return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) );
284
-	}
285
-
286
-	/**
287
-	 * Processes ipns and marks payments as complete.
288
-	 *
289
-	 * @return void
290
-	 */
291
-	public function verify_ipn() {}
292
-
293
-	/**
294
-	 * Get a link to the transaction on the 3rd party gateway site (if applicable).
295
-	 *
296
-	 * @param string $transaction_url transaction url.
297
-	 * @param WPInv_Invoice $invoice Invoice object.
298
-	 * @return string transaction URL, or empty string.
299
-	 */
300
-	public function filter_transaction_url( $transaction_url, $invoice ) {
301
-
302
-		$transaction_id  = $invoice->get_transaction_id();
303
-
304
-		if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) {
305
-			$transaction_url = sprintf( $this->view_transaction_url, $transaction_id );
306
-			$replace         = $this->is_sandbox( $invoice ) ? 'sandbox' : '';
307
-			$transaction_url = str_replace( '{sandbox}', $replace, $transaction_url );
308
-		}
309
-
310
-		return $transaction_url;
311
-	}
312
-
313
-	/**
314
-	 * Get a link to the subscription on the 3rd party gateway site (if applicable).
315
-	 *
316
-	 * @param string $subscription_url transaction url.
317
-	 * @param WPInv_Invoice $invoice Invoice object.
318
-	 * @return string subscription URL, or empty string.
319
-	 */
320
-	public function filter_subscription_url( $subscription_url, $invoice ) {
321
-
322
-		$profile_id      = $invoice->get_subscription_id();
323
-
324
-		if ( ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) {
325
-
326
-			$subscription_url = sprintf( $this->view_subscription_url, $profile_id );
327
-			$replace          = $this->is_sandbox( $invoice ) ? 'sandbox' : '';
328
-			$subscription_url = str_replace( '{sandbox}', $replace, $subscription_url );
329
-
330
-		}
331
-
332
-		return $subscription_url;
333
-	}
334
-
335
-	/**
336
-	 * Check if the gateway is available for use.
337
-	 *
338
-	 * @return bool
339
-	 */
340
-	public function is_available() {
341
-		return ! empty( $this->enabled );
342
-	}
343
-
344
-	/**
345
-	 * Return the gateway's title.
346
-	 *
347
-	 * @return string
348
-	 */
349
-	public function get_title() {
350
-		return apply_filters( 'getpaid_gateway_title', $this->title, $this );
351
-	}
352
-
353
-	/**
354
-	 * Return the gateway's description.
355
-	 *
356
-	 * @return string
357
-	 */
358
-	public function get_description() {
359
-		return apply_filters( 'getpaid_gateway_description', $this->description, $this );
360
-	}
361
-
362
-	/**
363
-	 * Process Payment.
364
-	 *
365
-	 *
366
-	 * @param WPInv_Invoice $invoice Invoice.
367
-	 * @param array $submission_data Posted checkout fields.
368
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
369
-	 * @return void
370
-	 */
371
-	public function process_payment( $invoice, $submission_data, $submission ) {
372
-		// Process the payment then either redirect to the success page or the gateway.
373
-	}
374
-
375
-	/**
376
-	 * Process refund.
377
-	 *
378
-	 * If the gateway declares 'refunds' support, this will allow it to refund.
379
-	 * a passed in amount.
380
-	 *
381
-	 * @param WPInv_Invoice $invoice Invoice.
382
-	 * @param  float  $amount Refund amount.
383
-	 * @param  string $reason Refund reason.
384
-	 * @return WP_Error|bool True or false based on success, or a WP_Error object.
385
-	 */
386
-	public function process_refund( $invoice, $amount = null, $reason = '' ) {
387
-		return false;
388
-	}
389
-
390
-	/**
391
-	 * Displays the payment fields, credit cards etc.
392
-	 * 
393
-	 * @param int $invoice_id 0 or invoice id.
394
-	 * @param GetPaid_Payment_Form $form Current payment form.
395
-	 */
396
-	public function payment_fields( $invoice_id, $form ) {}
397
-
398
-	/**
399
-	 * Filters the gateway settings.
400
-	 * 
401
-	 * @param array $admin_settings
402
-	 */
403
-	public function admin_settings( $admin_settings ) {
404
-		return $admin_settings;
405
-	}
406
-
407
-	/**
408
-	 * Retrieves the value of a gateway setting.
409
-	 * 
410
-	 * @param string $option
411
-	 */
412
-	public function get_option( $option, $default = false ) {
413
-		return wpinv_get_option( $this->id . '_' . $option, $default );
414
-	}
415
-
416
-	/**
417
-	 * Check if a gateway supports a given feature.
418
-	 *
419
-	 * Gateways should override this to declare support (or lack of support) for a feature.
420
-	 * For backward compatibility, gateways support 'products' by default, but nothing else.
421
-	 *
422
-	 * @param string $feature string The name of a feature to test support for.
423
-	 * @return bool True if the gateway supports the feature, false otherwise.
424
-	 * @since 1.0.19
425
-	 */
426
-	public function supports( $feature ) {
427
-		return apply_filters( 'getpaid_payment_gateway_supports', in_array( $feature, $this->supports ), $feature, $this );
428
-	}
429
-
430
-	/**
431
-	 * Grab and display our saved payment methods.
432
-	 *
433
-	 * @since 1.0.19
434
-	 */
435
-	public function saved_payment_methods() {
436
-		$html = '<ul class="getpaid-saved-payment-methods" data-count="' . esc_attr( count( $this->get_tokens() ) ) . '">';
437
-
438
-		foreach ( $this->get_tokens() as $token ) {
439
-			$html .= $this->get_saved_payment_method_option_html( $token );
440
-		}
441
-
442
-		$html .= $this->get_new_payment_method_option_html();
443
-		$html .= '</ul>';
444
-
445
-		echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this );
446
-	}
447
-
448
-	/**
449
-	 * Gets saved payment method HTML from a token.
450
-	 *
451
-	 * @since 1.0.19
452
-	 * @param  array $token Payment Token.
453
-	 * @return string Generated payment method HTML
454
-	 */
455
-	public function get_saved_payment_method_option_html( $token ) {
456
-
457
-		return sprintf(
458
-			'<li class="getpaid-payment-method form-group">
282
+        // Show payment processing indicator.
283
+        return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) );
284
+    }
285
+
286
+    /**
287
+     * Processes ipns and marks payments as complete.
288
+     *
289
+     * @return void
290
+     */
291
+    public function verify_ipn() {}
292
+
293
+    /**
294
+     * Get a link to the transaction on the 3rd party gateway site (if applicable).
295
+     *
296
+     * @param string $transaction_url transaction url.
297
+     * @param WPInv_Invoice $invoice Invoice object.
298
+     * @return string transaction URL, or empty string.
299
+     */
300
+    public function filter_transaction_url( $transaction_url, $invoice ) {
301
+
302
+        $transaction_id  = $invoice->get_transaction_id();
303
+
304
+        if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) {
305
+            $transaction_url = sprintf( $this->view_transaction_url, $transaction_id );
306
+            $replace         = $this->is_sandbox( $invoice ) ? 'sandbox' : '';
307
+            $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url );
308
+        }
309
+
310
+        return $transaction_url;
311
+    }
312
+
313
+    /**
314
+     * Get a link to the subscription on the 3rd party gateway site (if applicable).
315
+     *
316
+     * @param string $subscription_url transaction url.
317
+     * @param WPInv_Invoice $invoice Invoice object.
318
+     * @return string subscription URL, or empty string.
319
+     */
320
+    public function filter_subscription_url( $subscription_url, $invoice ) {
321
+
322
+        $profile_id      = $invoice->get_subscription_id();
323
+
324
+        if ( ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) {
325
+
326
+            $subscription_url = sprintf( $this->view_subscription_url, $profile_id );
327
+            $replace          = $this->is_sandbox( $invoice ) ? 'sandbox' : '';
328
+            $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url );
329
+
330
+        }
331
+
332
+        return $subscription_url;
333
+    }
334
+
335
+    /**
336
+     * Check if the gateway is available for use.
337
+     *
338
+     * @return bool
339
+     */
340
+    public function is_available() {
341
+        return ! empty( $this->enabled );
342
+    }
343
+
344
+    /**
345
+     * Return the gateway's title.
346
+     *
347
+     * @return string
348
+     */
349
+    public function get_title() {
350
+        return apply_filters( 'getpaid_gateway_title', $this->title, $this );
351
+    }
352
+
353
+    /**
354
+     * Return the gateway's description.
355
+     *
356
+     * @return string
357
+     */
358
+    public function get_description() {
359
+        return apply_filters( 'getpaid_gateway_description', $this->description, $this );
360
+    }
361
+
362
+    /**
363
+     * Process Payment.
364
+     *
365
+     *
366
+     * @param WPInv_Invoice $invoice Invoice.
367
+     * @param array $submission_data Posted checkout fields.
368
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
369
+     * @return void
370
+     */
371
+    public function process_payment( $invoice, $submission_data, $submission ) {
372
+        // Process the payment then either redirect to the success page or the gateway.
373
+    }
374
+
375
+    /**
376
+     * Process refund.
377
+     *
378
+     * If the gateway declares 'refunds' support, this will allow it to refund.
379
+     * a passed in amount.
380
+     *
381
+     * @param WPInv_Invoice $invoice Invoice.
382
+     * @param  float  $amount Refund amount.
383
+     * @param  string $reason Refund reason.
384
+     * @return WP_Error|bool True or false based on success, or a WP_Error object.
385
+     */
386
+    public function process_refund( $invoice, $amount = null, $reason = '' ) {
387
+        return false;
388
+    }
389
+
390
+    /**
391
+     * Displays the payment fields, credit cards etc.
392
+     * 
393
+     * @param int $invoice_id 0 or invoice id.
394
+     * @param GetPaid_Payment_Form $form Current payment form.
395
+     */
396
+    public function payment_fields( $invoice_id, $form ) {}
397
+
398
+    /**
399
+     * Filters the gateway settings.
400
+     * 
401
+     * @param array $admin_settings
402
+     */
403
+    public function admin_settings( $admin_settings ) {
404
+        return $admin_settings;
405
+    }
406
+
407
+    /**
408
+     * Retrieves the value of a gateway setting.
409
+     * 
410
+     * @param string $option
411
+     */
412
+    public function get_option( $option, $default = false ) {
413
+        return wpinv_get_option( $this->id . '_' . $option, $default );
414
+    }
415
+
416
+    /**
417
+     * Check if a gateway supports a given feature.
418
+     *
419
+     * Gateways should override this to declare support (or lack of support) for a feature.
420
+     * For backward compatibility, gateways support 'products' by default, but nothing else.
421
+     *
422
+     * @param string $feature string The name of a feature to test support for.
423
+     * @return bool True if the gateway supports the feature, false otherwise.
424
+     * @since 1.0.19
425
+     */
426
+    public function supports( $feature ) {
427
+        return apply_filters( 'getpaid_payment_gateway_supports', in_array( $feature, $this->supports ), $feature, $this );
428
+    }
429
+
430
+    /**
431
+     * Grab and display our saved payment methods.
432
+     *
433
+     * @since 1.0.19
434
+     */
435
+    public function saved_payment_methods() {
436
+        $html = '<ul class="getpaid-saved-payment-methods" data-count="' . esc_attr( count( $this->get_tokens() ) ) . '">';
437
+
438
+        foreach ( $this->get_tokens() as $token ) {
439
+            $html .= $this->get_saved_payment_method_option_html( $token );
440
+        }
441
+
442
+        $html .= $this->get_new_payment_method_option_html();
443
+        $html .= '</ul>';
444
+
445
+        echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this );
446
+    }
447
+
448
+    /**
449
+     * Gets saved payment method HTML from a token.
450
+     *
451
+     * @since 1.0.19
452
+     * @param  array $token Payment Token.
453
+     * @return string Generated payment method HTML
454
+     */
455
+    public function get_saved_payment_method_option_html( $token ) {
456
+
457
+        return sprintf(
458
+            '<li class="getpaid-payment-method form-group">
459 459
 				<label>
460 460
 					<input name="getpaid-%1$s-payment-method" type="radio" value="%2$s" style="width:auto;" class="getpaid-saved-payment-method-token-input" %4$s />
461 461
 					<span>%3$s</span>
462 462
 				</label>
463 463
 			</li>',
464
-			esc_attr( $this->id ),
465
-			esc_attr( $token['id'] ),
466
-			esc_html( $token['name'] ),
467
-			checked( empty( $token['default'] ), false, false )
468
-		);
464
+            esc_attr( $this->id ),
465
+            esc_attr( $token['id'] ),
466
+            esc_html( $token['name'] ),
467
+            checked( empty( $token['default'] ), false, false )
468
+        );
469 469
 
470
-	}
470
+    }
471 471
 
472
-	/**
473
-	 * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method.
474
-	 *
475
-	 * @since 1.0.19
476
-	 */
477
-	public function get_new_payment_method_option_html() {
472
+    /**
473
+     * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method.
474
+     *
475
+     * @since 1.0.19
476
+     */
477
+    public function get_new_payment_method_option_html() {
478 478
 
479
-		$label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this );
479
+        $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this );
480 480
 
481
-		return sprintf(
482
-			'<li class="getpaid-new-payment-method">
481
+        return sprintf(
482
+            '<li class="getpaid-new-payment-method">
483 483
 				<label>
484 484
 					<input name="getpaid-%1$s-payment-method" type="radio" value="new" style="width:auto;" />
485 485
 					<span>%2$s</span>
486 486
 				</label>
487 487
 			</li>',
488
-			esc_attr( $this->id ),
489
-			esc_html( $label )
490
-		);
491
-
492
-	}
493
-
494
-	/**
495
-	 * Outputs a checkbox for saving a new payment method to the database.
496
-	 *
497
-	 * @since 1.0.19
498
-	 */
499
-	public function save_payment_method_checkbox() {
488
+            esc_attr( $this->id ),
489
+            esc_html( $label )
490
+        );
491
+
492
+    }
493
+
494
+    /**
495
+     * Outputs a checkbox for saving a new payment method to the database.
496
+     *
497
+     * @since 1.0.19
498
+     */
499
+    public function save_payment_method_checkbox() {
500 500
 	
501
-		return sprintf(
502
-			'<p class="form-group getpaid-save-payment-method">
501
+        return sprintf(
502
+            '<p class="form-group getpaid-save-payment-method">
503 503
 				<label>
504 504
 					<input name="getpaid-%1$s-new-payment-method" type="checkbox" value="true" style="width:auto;" />
505 505
 					<span>%2$s</span>
506 506
 				</label>
507 507
 			</p>',
508
-			esc_attr( $this->id ),
509
-			esc_html__( 'Save payment method', 'invoicing' )
510
-		);
508
+            esc_attr( $this->id ),
509
+            esc_html__( 'Save payment method', 'invoicing' )
510
+        );
511 511
 
512
-	}
512
+    }
513 513
 
514
-	/**
515
-	 * Registers the gateway.
516
-	 *
517
-	 * @return array
518
-	 */
519
-	public function register_gateway( $gateways ) {
514
+    /**
515
+     * Registers the gateway.
516
+     *
517
+     * @return array
518
+     */
519
+    public function register_gateway( $gateways ) {
520 520
 
521
-		$gateways[ $this->id ] = array(
521
+        $gateways[ $this->id ] = array(
522 522
 
523
-			'admin_label'    => $this->method_title,
523
+            'admin_label'    => $this->method_title,
524 524
             'checkout_label' => $this->title,
525
-			'ordering'       => $this->order,
526
-
527
-		);
528
-
529
-		return $gateways;
530
-
531
-	}
532
-
533
-	/**
534
-	 * Checks whether or not this is a sandbox request.
535
-	 *
536
-	 * @param  WPInv_Invoice|null $invoice Invoice object or null.
537
-	 * @return bool
538
-	 */
539
-	public function is_sandbox( $invoice = null ) {
540
-
541
-		if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) {
542
-			return $invoice->get_mode() == 'test';
543
-		}
544
-
545
-		return wpinv_is_test_mode( $this->id );
546
-
547
-	}
548
-
549
-	/**
550
-	 * Renames the checkout button
551
-	 *
552
-	 * @return string
553
-	 */
554
-	public function rename_checkout_button() {
555
-		return $this->checkout_button_text;
556
-	}
557
-
558
-	/**
559
-	 * Validate gateway currency
560
-	 *
561
-	 * @return bool
562
-	 */
563
-	public function validate_currency( $validation, $currency ) {
564
-
565
-		// Required currencies.
566
-		if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) {
567
-			return false;
568
-		}
569
-
570
-		// Excluded currencies.
571
-		if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) {
572
-			return false;
573
-		}
574
-
575
-		return $validation;
576
-	}
525
+            'ordering'       => $this->order,
526
+
527
+        );
528
+
529
+        return $gateways;
530
+
531
+    }
532
+
533
+    /**
534
+     * Checks whether or not this is a sandbox request.
535
+     *
536
+     * @param  WPInv_Invoice|null $invoice Invoice object or null.
537
+     * @return bool
538
+     */
539
+    public function is_sandbox( $invoice = null ) {
540
+
541
+        if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) {
542
+            return $invoice->get_mode() == 'test';
543
+        }
544
+
545
+        return wpinv_is_test_mode( $this->id );
546
+
547
+    }
548
+
549
+    /**
550
+     * Renames the checkout button
551
+     *
552
+     * @return string
553
+     */
554
+    public function rename_checkout_button() {
555
+        return $this->checkout_button_text;
556
+    }
557
+
558
+    /**
559
+     * Validate gateway currency
560
+     *
561
+     * @return bool
562
+     */
563
+    public function validate_currency( $validation, $currency ) {
564
+
565
+        // Required currencies.
566
+        if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) {
567
+            return false;
568
+        }
569
+
570
+        // Excluded currencies.
571
+        if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) {
572
+            return false;
573
+        }
574
+
575
+        return $validation;
576
+    }
577 577
 
578 578
 }
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 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
  * Abstaract Payment Gateway class.
@@ -137,50 +137,50 @@  discard block
 block discarded – undo
137 137
 	 * Class constructor.
138 138
 	 */
139 139
 	public function __construct() {
140
-		$this->enabled = wpinv_is_gateway_active( $this->id );
140
+		$this->enabled = wpinv_is_gateway_active($this->id);
141 141
 
142 142
 		// Register gateway.
143
-		add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) );
143
+		add_filter('wpinv_payment_gateways', array($this, 'register_gateway'));
144 144
 
145 145
 		// Enable Subscriptions.
146
-		if ( $this->supports( 'subscription' ) ) {
147
-			add_filter( "wpinv_{$this->id}_support_subscription", '__return_true' );
146
+		if ($this->supports('subscription')) {
147
+			add_filter("wpinv_{$this->id}_support_subscription", '__return_true');
148 148
 		}
149 149
 
150 150
 		// Enable sandbox.
151
-		if ( $this->supports( 'sandbox' ) ) {
152
-			add_filter( "wpinv_{$this->id}_supports_sandbox", '__return_true' );
151
+		if ($this->supports('sandbox')) {
152
+			add_filter("wpinv_{$this->id}_supports_sandbox", '__return_true');
153 153
 		}
154 154
 
155 155
 		// Gateway settings.
156
-		add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) );
156
+		add_filter("wpinv_gateway_settings_{$this->id}", array($this, 'admin_settings'));
157 157
 		
158 158
 
159 159
 		// Gateway checkout fiellds.
160
-		add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 );
160
+		add_action("wpinv_{$this->id}_cc_form", array($this, 'payment_fields'), 10, 2);
161 161
 
162 162
 		// Process payment.
163
-		add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 );
163
+		add_action("getpaid_gateway_{$this->id}", array($this, 'process_payment'), 10, 3);
164 164
 
165 165
 		// Change the checkout button text.
166
-		if ( ! empty( $this->checkout_button_text ) ) {
167
-			add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) );
166
+		if (!empty($this->checkout_button_text)) {
167
+			add_filter("getpaid_gateway_{$this->id}_checkout_button_label", array($this, 'rename_checkout_button'));
168 168
 		}
169 169
 
170 170
 		// Check if a gateway is valid for a given currency.
171
-		add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 );
171
+		add_filter("getpaid_gateway_{$this->id}_is_valid_for_currency", array($this, 'validate_currency'), 10, 2);
172 172
 
173 173
 		// Generate the transaction url.
174
-		add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 );
174
+		add_filter("getpaid_gateway_{$this->id}_transaction_url", array($this, 'filter_transaction_url'), 10, 2);
175 175
 
176 176
 		// Generate the subscription url.
177
-		add_filter( "getpaid_gateway_{$this->id}_subscription_url", array( $this, 'filter_subscription_url' ), 10, 2 );
177
+		add_filter("getpaid_gateway_{$this->id}_subscription_url", array($this, 'filter_subscription_url'), 10, 2);
178 178
 
179 179
 		// Confirm payments.
180
-		add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 );
180
+		add_filter("wpinv_payment_confirm_{$this->id}", array($this, 'confirm_payment'), 10, 2);
181 181
 
182 182
 		// Verify IPNs.
183
-		add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) );
183
+		add_action("wpinv_verify_{$this->id}_ipn", array($this, 'verify_ipn'));
184 184
 
185 185
 	}
186 186
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 * @since 1.0.19
191 191
 	 * @return bool
192 192
 	 */
193
-	public function is( $gateway ) {
193
+	public function is($gateway) {
194 194
 		return $gateway == $this->id;
195 195
 	}
196 196
 
@@ -202,14 +202,14 @@  discard block
 block discarded – undo
202 202
 	 */
203 203
 	public function get_tokens() {
204 204
 
205
-		if ( count( $this->tokens ) > 0 ) {
205
+		if (count($this->tokens) > 0) {
206 206
 			return $this->tokens;
207 207
 		}
208 208
 
209
-		if ( is_user_logged_in() && $this->supports( 'tokens' ) ) {
210
-			$tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true );
209
+		if (is_user_logged_in() && $this->supports('tokens')) {
210
+			$tokens = get_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", true);
211 211
 
212
-			if ( is_array( $tokens ) ) {
212
+			if (is_array($tokens)) {
213 213
 				$this->tokens = $tokens;
214 214
 			}
215 215
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 	 * @return string
225 225
 	 */
226 226
 	public function get_method_title() {
227
-		return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this );
227
+		return apply_filters('getpaid_gateway_method_title', $this->method_title, $this);
228 228
 	}
229 229
 
230 230
 	/**
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	 * @return string
234 234
 	 */
235 235
 	public function get_method_description() {
236
-		return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this );
236
+		return apply_filters('getpaid_gateway_method_description', $this->method_description, $this);
237 237
 	}
238 238
 
239 239
 	/**
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
 	 * @param WPInv_Invoice $invoice Invoice object.
243 243
 	 * @return string
244 244
 	 */
245
-	public function get_return_url( $invoice ) {
245
+	public function get_return_url($invoice) {
246 246
 
247 247
 		// Payment success url
248 248
 		$return_url = add_query_arg(
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
 			wpinv_get_success_page_uri()
255 255
 		);
256 256
 
257
-		return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this );
257
+		return apply_filters('getpaid_gateway_success_url', $return_url, $invoice, $this);
258 258
 	}
259 259
 
260 260
 	/**
@@ -263,24 +263,24 @@  discard block
 block discarded – undo
263 263
 	 * @param string $content Success page content.
264 264
 	 * @return string
265 265
 	 */
266
-	public function get_confirm_payment( $content ) {
266
+	public function get_confirm_payment($content) {
267 267
 		
268 268
 		// Retrieve the invoice.
269 269
 		$invoice_id = getpaid_get_current_invoice_id();
270
-		$invoice    = wpinv_get_invoice( $invoice_id );
270
+		$invoice    = wpinv_get_invoice($invoice_id);
271 271
 	
272 272
 		// Ensure that it exists and that it is pending payment.
273
-		if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) {
273
+		if (empty($invoice_id) || !$invoice->needs_payment()) {
274 274
 			return $content;
275 275
 		}
276 276
 	
277 277
 		// Can the user view this invoice??
278
-		if ( ! wpinv_user_can_view_invoice( $invoice ) ) {
278
+		if (!wpinv_user_can_view_invoice($invoice)) {
279 279
 			return $content;
280 280
 		}
281 281
 	
282 282
 		// Show payment processing indicator.
283
-		return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) );
283
+		return wpinv_get_template_html('wpinv-payment-processing.php', compact('invoice'));
284 284
 	}
285 285
 
286 286
 	/**
@@ -297,14 +297,14 @@  discard block
 block discarded – undo
297 297
 	 * @param WPInv_Invoice $invoice Invoice object.
298 298
 	 * @return string transaction URL, or empty string.
299 299
 	 */
300
-	public function filter_transaction_url( $transaction_url, $invoice ) {
300
+	public function filter_transaction_url($transaction_url, $invoice) {
301 301
 
302
-		$transaction_id  = $invoice->get_transaction_id();
302
+		$transaction_id = $invoice->get_transaction_id();
303 303
 
304
-		if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) {
305
-			$transaction_url = sprintf( $this->view_transaction_url, $transaction_id );
306
-			$replace         = $this->is_sandbox( $invoice ) ? 'sandbox' : '';
307
-			$transaction_url = str_replace( '{sandbox}', $replace, $transaction_url );
304
+		if (!empty($this->view_transaction_url) && !empty($transaction_id)) {
305
+			$transaction_url = sprintf($this->view_transaction_url, $transaction_id);
306
+			$replace         = $this->is_sandbox($invoice) ? 'sandbox' : '';
307
+			$transaction_url = str_replace('{sandbox}', $replace, $transaction_url);
308 308
 		}
309 309
 
310 310
 		return $transaction_url;
@@ -317,15 +317,15 @@  discard block
 block discarded – undo
317 317
 	 * @param WPInv_Invoice $invoice Invoice object.
318 318
 	 * @return string subscription URL, or empty string.
319 319
 	 */
320
-	public function filter_subscription_url( $subscription_url, $invoice ) {
320
+	public function filter_subscription_url($subscription_url, $invoice) {
321 321
 
322
-		$profile_id      = $invoice->get_subscription_id();
322
+		$profile_id = $invoice->get_subscription_id();
323 323
 
324
-		if ( ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) {
324
+		if (!empty($this->view_subscription_url) && !empty($profile_id)) {
325 325
 
326
-			$subscription_url = sprintf( $this->view_subscription_url, $profile_id );
327
-			$replace          = $this->is_sandbox( $invoice ) ? 'sandbox' : '';
328
-			$subscription_url = str_replace( '{sandbox}', $replace, $subscription_url );
326
+			$subscription_url = sprintf($this->view_subscription_url, $profile_id);
327
+			$replace          = $this->is_sandbox($invoice) ? 'sandbox' : '';
328
+			$subscription_url = str_replace('{sandbox}', $replace, $subscription_url);
329 329
 
330 330
 		}
331 331
 
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 	 * @return bool
339 339
 	 */
340 340
 	public function is_available() {
341
-		return ! empty( $this->enabled );
341
+		return !empty($this->enabled);
342 342
 	}
343 343
 
344 344
 	/**
@@ -347,7 +347,7 @@  discard block
 block discarded – undo
347 347
 	 * @return string
348 348
 	 */
349 349
 	public function get_title() {
350
-		return apply_filters( 'getpaid_gateway_title', $this->title, $this );
350
+		return apply_filters('getpaid_gateway_title', $this->title, $this);
351 351
 	}
352 352
 
353 353
 	/**
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
 	 * @return string
357 357
 	 */
358 358
 	public function get_description() {
359
-		return apply_filters( 'getpaid_gateway_description', $this->description, $this );
359
+		return apply_filters('getpaid_gateway_description', $this->description, $this);
360 360
 	}
361 361
 
362 362
 	/**
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
369 369
 	 * @return void
370 370
 	 */
371
-	public function process_payment( $invoice, $submission_data, $submission ) {
371
+	public function process_payment($invoice, $submission_data, $submission) {
372 372
 		// Process the payment then either redirect to the success page or the gateway.
373 373
 	}
374 374
 
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 	 * @param  string $reason Refund reason.
384 384
 	 * @return WP_Error|bool True or false based on success, or a WP_Error object.
385 385
 	 */
386
-	public function process_refund( $invoice, $amount = null, $reason = '' ) {
386
+	public function process_refund($invoice, $amount = null, $reason = '') {
387 387
 		return false;
388 388
 	}
389 389
 
@@ -393,14 +393,14 @@  discard block
 block discarded – undo
393 393
 	 * @param int $invoice_id 0 or invoice id.
394 394
 	 * @param GetPaid_Payment_Form $form Current payment form.
395 395
 	 */
396
-	public function payment_fields( $invoice_id, $form ) {}
396
+	public function payment_fields($invoice_id, $form) {}
397 397
 
398 398
 	/**
399 399
 	 * Filters the gateway settings.
400 400
 	 * 
401 401
 	 * @param array $admin_settings
402 402
 	 */
403
-	public function admin_settings( $admin_settings ) {
403
+	public function admin_settings($admin_settings) {
404 404
 		return $admin_settings;
405 405
 	}
406 406
 
@@ -409,8 +409,8 @@  discard block
 block discarded – undo
409 409
 	 * 
410 410
 	 * @param string $option
411 411
 	 */
412
-	public function get_option( $option, $default = false ) {
413
-		return wpinv_get_option( $this->id . '_' . $option, $default );
412
+	public function get_option($option, $default = false) {
413
+		return wpinv_get_option($this->id . '_' . $option, $default);
414 414
 	}
415 415
 
416 416
 	/**
@@ -423,8 +423,8 @@  discard block
 block discarded – undo
423 423
 	 * @return bool True if the gateway supports the feature, false otherwise.
424 424
 	 * @since 1.0.19
425 425
 	 */
426
-	public function supports( $feature ) {
427
-		return apply_filters( 'getpaid_payment_gateway_supports', in_array( $feature, $this->supports ), $feature, $this );
426
+	public function supports($feature) {
427
+		return apply_filters('getpaid_payment_gateway_supports', in_array($feature, $this->supports), $feature, $this);
428 428
 	}
429 429
 
430 430
 	/**
@@ -433,16 +433,16 @@  discard block
 block discarded – undo
433 433
 	 * @since 1.0.19
434 434
 	 */
435 435
 	public function saved_payment_methods() {
436
-		$html = '<ul class="getpaid-saved-payment-methods" data-count="' . esc_attr( count( $this->get_tokens() ) ) . '">';
436
+		$html = '<ul class="getpaid-saved-payment-methods" data-count="' . esc_attr(count($this->get_tokens())) . '">';
437 437
 
438
-		foreach ( $this->get_tokens() as $token ) {
439
-			$html .= $this->get_saved_payment_method_option_html( $token );
438
+		foreach ($this->get_tokens() as $token) {
439
+			$html .= $this->get_saved_payment_method_option_html($token);
440 440
 		}
441 441
 
442 442
 		$html .= $this->get_new_payment_method_option_html();
443 443
 		$html .= '</ul>';
444 444
 
445
-		echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this );
445
+		echo apply_filters('getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this);
446 446
 	}
447 447
 
448 448
 	/**
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
 	 * @param  array $token Payment Token.
453 453
 	 * @return string Generated payment method HTML
454 454
 	 */
455
-	public function get_saved_payment_method_option_html( $token ) {
455
+	public function get_saved_payment_method_option_html($token) {
456 456
 
457 457
 		return sprintf(
458 458
 			'<li class="getpaid-payment-method form-group">
@@ -461,10 +461,10 @@  discard block
 block discarded – undo
461 461
 					<span>%3$s</span>
462 462
 				</label>
463 463
 			</li>',
464
-			esc_attr( $this->id ),
465
-			esc_attr( $token['id'] ),
466
-			esc_html( $token['name'] ),
467
-			checked( empty( $token['default'] ), false, false )
464
+			esc_attr($this->id),
465
+			esc_attr($token['id']),
466
+			esc_html($token['name']),
467
+			checked(empty($token['default']), false, false)
468 468
 		);
469 469
 
470 470
 	}
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
 	 */
477 477
 	public function get_new_payment_method_option_html() {
478 478
 
479
-		$label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this );
479
+		$label = apply_filters('getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __('Use a new payment method', 'invoicing'), $this);
480 480
 
481 481
 		return sprintf(
482 482
 			'<li class="getpaid-new-payment-method">
@@ -485,8 +485,8 @@  discard block
 block discarded – undo
485 485
 					<span>%2$s</span>
486 486
 				</label>
487 487
 			</li>',
488
-			esc_attr( $this->id ),
489
-			esc_html( $label )
488
+			esc_attr($this->id),
489
+			esc_html($label)
490 490
 		);
491 491
 
492 492
 	}
@@ -505,8 +505,8 @@  discard block
 block discarded – undo
505 505
 					<span>%2$s</span>
506 506
 				</label>
507 507
 			</p>',
508
-			esc_attr( $this->id ),
509
-			esc_html__( 'Save payment method', 'invoicing' )
508
+			esc_attr($this->id),
509
+			esc_html__('Save payment method', 'invoicing')
510 510
 		);
511 511
 
512 512
 	}
@@ -516,9 +516,9 @@  discard block
 block discarded – undo
516 516
 	 *
517 517
 	 * @return array
518 518
 	 */
519
-	public function register_gateway( $gateways ) {
519
+	public function register_gateway($gateways) {
520 520
 
521
-		$gateways[ $this->id ] = array(
521
+		$gateways[$this->id] = array(
522 522
 
523 523
 			'admin_label'    => $this->method_title,
524 524
             'checkout_label' => $this->title,
@@ -536,13 +536,13 @@  discard block
 block discarded – undo
536 536
 	 * @param  WPInv_Invoice|null $invoice Invoice object or null.
537 537
 	 * @return bool
538 538
 	 */
539
-	public function is_sandbox( $invoice = null ) {
539
+	public function is_sandbox($invoice = null) {
540 540
 
541
-		if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) {
541
+		if (!empty($invoice) && !$invoice->needs_payment()) {
542 542
 			return $invoice->get_mode() == 'test';
543 543
 		}
544 544
 
545
-		return wpinv_is_test_mode( $this->id );
545
+		return wpinv_is_test_mode($this->id);
546 546
 
547 547
 	}
548 548
 
@@ -560,15 +560,15 @@  discard block
 block discarded – undo
560 560
 	 *
561 561
 	 * @return bool
562 562
 	 */
563
-	public function validate_currency( $validation, $currency ) {
563
+	public function validate_currency($validation, $currency) {
564 564
 
565 565
 		// Required currencies.
566
-		if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) {
566
+		if (!empty($this->currencies) && !in_array($currency, $this->currencies)) {
567 567
 			return false;
568 568
 		}
569 569
 
570 570
 		// Excluded currencies.
571
-		if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) {
571
+		if (!empty($this->exclude_currencies) && in_array($currency, $this->exclude_currencies)) {
572 572
 			return false;
573 573
 		}
574 574
 
Please login to merge, or discard this patch.
includes/class-wpinv.php 2 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
         require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' );
179 179
 
180 180
         // Register autoloader.
181
-		try {
182
-			spl_autoload_register( array( $this, 'autoload' ), true );
183
-		} catch ( Exception $e ) {
184
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
181
+        try {
182
+            spl_autoload_register( array( $this, 'autoload' ), true );
183
+        } catch ( Exception $e ) {
184
+            wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
185 185
         }
186 186
 
187 187
         require_once( WPINV_PLUGIN_DIR . 'includes/class-getpaid-post-types.php' );
@@ -206,11 +206,11 @@  discard block
 block discarded – undo
206 206
         require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
207 207
         require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
208 208
         require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
209
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
210
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
211
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
212
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
213
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
209
+        require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
210
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
211
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
212
+        require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
213
+        require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
214 214
         require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
215 215
         require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
216 216
         require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
@@ -272,48 +272,48 @@  discard block
 block discarded – undo
272 272
     }
273 273
 
274 274
     /**
275
-	 * Class autoloader
276
-	 *
277
-	 * @param       string $class_name The name of the class to load.
278
-	 * @access      public
279
-	 * @since       1.0.19
280
-	 * @return      void
281
-	 */
282
-	public function autoload( $class_name ) {
283
-
284
-		// Normalize the class name...
285
-		$class_name  = strtolower( $class_name );
286
-
287
-		// ... and make sure it is our class.
288
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
289
-			return;
290
-		}
291
-
292
-		// Next, prepare the file name from the class.
293
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
275
+     * Class autoloader
276
+     *
277
+     * @param       string $class_name The name of the class to load.
278
+     * @access      public
279
+     * @since       1.0.19
280
+     * @return      void
281
+     */
282
+    public function autoload( $class_name ) {
283
+
284
+        // Normalize the class name...
285
+        $class_name  = strtolower( $class_name );
286
+
287
+        // ... and make sure it is our class.
288
+        if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
289
+            return;
290
+        }
291
+
292
+        // Next, prepare the file name from the class.
293
+        $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
294 294
 
295 295
         // Base path of the classes.
296 296
         $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
297 297
 
298
-		// And an array of possible locations in order of importance.
299
-		$locations = array(
298
+        // And an array of possible locations in order of importance.
299
+        $locations = array(
300 300
             "$plugin_path/includes",
301 301
             "$plugin_path/includes/data-stores",
302 302
             "$plugin_path/includes/gateways",
303 303
             "$plugin_path/includes/admin",
304 304
             "$plugin_path/includes/admin/meta-boxes",
305
-		);
305
+        );
306 306
 
307
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
307
+        foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
308 308
 
309
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
310
-				include trailingslashit( $location ) . $file_name;
311
-				break;
312
-			}
309
+            if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
310
+                include trailingslashit( $location ) . $file_name;
311
+                break;
312
+            }
313 313
 
314
-		}
314
+        }
315 315
 
316
-	}
316
+    }
317 317
 
318 318
     /**
319 319
      * Inits hooks etc.
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
             wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
428 428
             wp_enqueue_style( 'jquery-ui-css' );
429 429
             wp_deregister_style( 'yoast-seo-select2' );
430
-	        wp_deregister_style( 'yoast-seo-monorepo' );
430
+            wp_deregister_style( 'yoast-seo-monorepo' );
431 431
         }
432 432
 
433 433
         wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
         if ( $page == 'wpinv-subscriptions' ) {
442 442
             wp_enqueue_script( 'jquery-ui-datepicker' );
443 443
             wp_deregister_style( 'yoast-seo-select2' );
444
-	        wp_deregister_style( 'yoast-seo-monorepo' );
444
+            wp_deregister_style( 'yoast-seo-monorepo' );
445 445
         }
446 446
         
447 447
         if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) {
@@ -610,19 +610,19 @@  discard block
 block discarded – undo
610 610
         require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
611 611
     }
612 612
 
613
-	/**
614
-	 * Register widgets
615
-	 *
616
-	 */
617
-	public function register_widgets() {
618
-		register_widget( "WPInv_Checkout_Widget" );
619
-		register_widget( "WPInv_History_Widget" );
620
-		register_widget( "WPInv_Receipt_Widget" );
621
-		register_widget( "WPInv_Subscriptions_Widget" );
622
-		register_widget( "WPInv_Buy_Item_Widget" );
613
+    /**
614
+     * Register widgets
615
+     *
616
+     */
617
+    public function register_widgets() {
618
+        register_widget( "WPInv_Checkout_Widget" );
619
+        register_widget( "WPInv_History_Widget" );
620
+        register_widget( "WPInv_Receipt_Widget" );
621
+        register_widget( "WPInv_Subscriptions_Widget" );
622
+        register_widget( "WPInv_Buy_Item_Widget" );
623 623
         register_widget( "WPInv_Messages_Widget" );
624 624
         register_widget( 'WPInv_GetPaid_Widget' );
625
-	}
625
+    }
626 626
     
627 627
     /**
628 628
      * Remove our pages from yoast sitemaps.
Please login to merge, or discard this patch.
Spacing   +272 added lines, -272 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
  * Manual Payment Gateway class.
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
     public $gateways;
25 25
     
26 26
     public static function run() {
27
-        if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) {
27
+        if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) {
28 28
             self::$instance = new WPInv_Plugin;
29 29
             self::$instance->includes();
30 30
             self::$instance->actions();
@@ -47,37 +47,37 @@  discard block
 block discarded – undo
47 47
     }
48 48
     
49 49
     public function define_constants() {
50
-        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
51
-        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
50
+        define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
51
+        define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
52 52
     }
53 53
 
54 54
     private function actions() {
55 55
         /* Internationalize the text strings used. */
56
-        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
56
+        add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
57 57
         
58 58
         /* Perform actions on admin initialization. */
59
-        add_action( 'admin_init', array( &$this, 'admin_init') );
59
+        add_action('admin_init', array(&$this, 'admin_init'));
60 60
 
61 61
         // Init the plugin after WordPress inits.
62
-        add_action( 'init', array( $this, 'init' ), 1 );
63
-        add_action( 'init', array( &$this, 'wpinv_actions' ) );
62
+        add_action('init', array($this, 'init'), 1);
63
+        add_action('init', array(&$this, 'wpinv_actions'));
64 64
         
65
-        if ( class_exists( 'BuddyPress' ) ) {
66
-            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
65
+        if (class_exists('BuddyPress')) {
66
+            add_action('bp_include', array(&$this, 'bp_invoicing_init'));
67 67
         }
68 68
 
69
-        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
70
-        add_action( 'wp_footer', array( &$this, 'wp_footer' ) );
71
-        add_action( 'widgets_init', array( &$this, 'register_widgets' ) );
72
-        add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) );
69
+        add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
70
+        add_action('wp_footer', array(&$this, 'wp_footer'));
71
+        add_action('widgets_init', array(&$this, 'register_widgets'));
72
+        add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids'));
73 73
 
74
-        if ( is_admin() ) {
75
-            add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
76
-            add_filter( 'admin_body_class', array( &$this, 'admin_body_class' ) );
77
-            add_action( 'admin_init', array( &$this, 'init_ayecode_connect_helper' ) );
74
+        if (is_admin()) {
75
+            add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
76
+            add_filter('admin_body_class', array(&$this, 'admin_body_class'));
77
+            add_action('admin_init', array(&$this, 'init_ayecode_connect_helper'));
78 78
 
79 79
         } else {
80
-            add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
80
+            add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
81 81
         }
82 82
         
83 83
         /**
@@ -87,28 +87,28 @@  discard block
 block discarded – undo
87 87
          *
88 88
          * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference.
89 89
          */
90
-        do_action_ref_array( 'wpinv_actions', array( &$this ) );
90
+        do_action_ref_array('wpinv_actions', array(&$this));
91 91
 
92
-        add_action( 'admin_init', array( &$this, 'activation_redirect') );
92
+        add_action('admin_init', array(&$this, 'activation_redirect'));
93 93
     }
94 94
 
95 95
     /**
96 96
      * Maybe show the AyeCode Connect Notice.
97 97
      */
98
-    public function init_ayecode_connect_helper(){
98
+    public function init_ayecode_connect_helper() {
99 99
         // AyeCode Connect notice
100
-        if ( is_admin() ){
100
+        if (is_admin()) {
101 101
             // set the strings so they can be translated
102 102
             $strings = array(
103
-                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
104
-                'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
105
-                'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
106
-                'connect_button'    => __("Connect Site","invoicing"),
107
-                'connecting_button'    => __("Connecting...","invoicing"),
108
-                'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
109
-                'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
103
+                'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
104
+                'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
105
+                'connect'           => sprintf(__("<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s", "invoicing"), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>"),
106
+                'connect_button'    => __("Connect Site", "invoicing"),
107
+                'connecting_button'    => __("Connecting...", "invoicing"),
108
+                'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
109
+                'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
110 110
             );
111
-            new AyeCode_Connect_Helper($strings,array('wpi-addons'));
111
+            new AyeCode_Connect_Helper($strings, array('wpi-addons'));
112 112
         }
113 113
     }
114 114
     
@@ -116,10 +116,10 @@  discard block
 block discarded – undo
116 116
         /* Internationalize the text strings used. */
117 117
         $this->load_textdomain();
118 118
 
119
-        do_action( 'wpinv_loaded' );
119
+        do_action('wpinv_loaded');
120 120
 
121 121
         // Fix oxygen page builder conflict
122
-        if ( function_exists( 'ct_css_output' ) ) {
122
+        if (function_exists('ct_css_output')) {
123 123
             wpinv_oxygen_fix_conflict();
124 124
         }
125 125
     }
@@ -129,146 +129,146 @@  discard block
 block discarded – undo
129 129
      *
130 130
      * @since 1.0
131 131
      */
132
-    public function load_textdomain( $locale = NULL ) {
133
-        if ( empty( $locale ) ) {
134
-            $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
132
+    public function load_textdomain($locale = NULL) {
133
+        if (empty($locale)) {
134
+            $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
135 135
         }
136 136
 
137
-        $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
137
+        $locale = apply_filters('plugin_locale', $locale, 'invoicing');
138 138
         
139
-        unload_textdomain( 'invoicing' );
140
-        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
141
-        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
139
+        unload_textdomain('invoicing');
140
+        load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
141
+        load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
142 142
         
143 143
         /**
144 144
          * Define language constants.
145 145
          */
146
-        require_once( WPINV_PLUGIN_DIR . 'language.php' );
146
+        require_once(WPINV_PLUGIN_DIR . 'language.php');
147 147
     }
148 148
 
149 149
     public function includes() {
150 150
         global $wpinv_options;
151 151
 
152
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
152
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
153 153
         $wpinv_options = wpinv_get_settings();
154 154
 
155 155
         // Load composer packages.
156
-        require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
156
+        require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php');
157 157
 
158 158
         // load AUI
159
-        require_once( WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php' );
159
+        require_once(WPINV_PLUGIN_DIR . 'vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php');
160 160
 
161 161
         // Load the action scheduler.
162
-        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php' );
162
+        require_once(WPINV_PLUGIN_DIR . 'includes/libraries/action-scheduler/action-scheduler.php');
163 163
 
164 164
         // Load functions.
165
-        require_once( WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php' );
166
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
167
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
168
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
169
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
170
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
171
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
172
-        require_once( WPINV_PLUGIN_DIR . 'includes/invoice-functions.php' );
173
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
174
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
175
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
176
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
177
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
178
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' );
165
+        require_once(WPINV_PLUGIN_DIR . 'includes/deprecated-functions.php');
166
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
167
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
168
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
169
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
170
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
171
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
172
+        require_once(WPINV_PLUGIN_DIR . 'includes/invoice-functions.php');
173
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
174
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
175
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
176
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
177
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php');
178
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php');
179 179
 
180 180
         // Register autoloader.
181 181
 		try {
182
-			spl_autoload_register( array( $this, 'autoload' ), true );
183
-		} catch ( Exception $e ) {
184
-			wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true );
185
-        }
186
-
187
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-getpaid-post-types.php' );
188
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' );
189
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' );
190
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php' );
191
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' );
192
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' );
193
-        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
194
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
195
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
196
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
197
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
198
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
199
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
200
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
201
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
202
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' );
203
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
204
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' );
205
-        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
206
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
207
-        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
208
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
209
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/checkout.php' );
210
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-history.php' );
211
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php' );
212
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php' );
213
-	    require_once( WPINV_PLUGIN_DIR . 'widgets/subscriptions.php' );
214
-        require_once( WPINV_PLUGIN_DIR . 'widgets/buy-item.php' );
215
-        require_once( WPINV_PLUGIN_DIR . 'widgets/getpaid.php' );
216
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php' );
182
+			spl_autoload_register(array($this, 'autoload'), true);
183
+		} catch (Exception $e) {
184
+			wpinv_error_log($e->getMessage(), '', __FILE__, 149, true);
185
+        }
186
+
187
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-getpaid-post-types.php');
188
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php');
189
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php');
190
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-discount.php');
191
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php');
192
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php');
193
+        require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php');
194
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php');
195
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
196
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
197
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
198
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php');
199
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php');
200
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php');
201
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php');
202
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php');
203
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php');
204
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php');
205
+        require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php');
206
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php');
207
+        require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php');
208
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php');
209
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/checkout.php');
210
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-history.php');
211
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-receipt.php');
212
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/invoice-messages.php');
213
+	    require_once(WPINV_PLUGIN_DIR . 'widgets/subscriptions.php');
214
+        require_once(WPINV_PLUGIN_DIR . 'widgets/buy-item.php');
215
+        require_once(WPINV_PLUGIN_DIR . 'widgets/getpaid.php');
216
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-payment-form-elements.php');
217 217
 
218 218
         /**
219 219
          * Load the tax class.
220 220
          */
221
-        if ( ! class_exists( 'WPInv_EUVat' ) ) {
222
-            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
221
+        if (!class_exists('WPInv_EUVat')) {
222
+            require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
223 223
         }
224 224
 
225
-        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
226
-        if ( !empty( $gateways ) ) {
227
-            foreach ( $gateways as $gateway ) {
228
-                if ( $gateway == 'manual' ) {
225
+        $gateways = array_keys(wpinv_get_enabled_payment_gateways());
226
+        if (!empty($gateways)) {
227
+            foreach ($gateways as $gateway) {
228
+                if ($gateway == 'manual') {
229 229
                     continue;
230 230
                 }
231 231
                 
232 232
                 $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
233 233
                 
234
-                if ( file_exists( $gateway_file ) ) {
235
-                    require_once( $gateway_file );
234
+                if (file_exists($gateway_file)) {
235
+                    require_once($gateway_file);
236 236
                 }
237 237
             }
238 238
         }
239 239
         
240
-        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
240
+        if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
241 241
             GetPaid_Post_Types_Admin::init();
242 242
 
243
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
244
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
243
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php');
244
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
245 245
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' );
246
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php' );
247
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
248
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
249
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
250
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
251
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php' );
246
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-payment-form.php');
247
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
248
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
249
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php');
250
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php');
251
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php');
252 252
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
253 253
             // load the user class only on the users.php page
254 254
             global $pagenow;
255
-            if($pagenow=='users.php'){
255
+            if ($pagenow == 'users.php') {
256 256
                 new WPInv_Admin_Users();
257 257
             }
258 258
         }
259 259
 
260 260
         // Register cli commands
261
-        if ( defined( 'WP_CLI' ) && WP_CLI ) {
262
-            require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php' );
263
-            WP_CLI::add_command( 'invoicing', 'WPInv_CLI' );
261
+        if (defined('WP_CLI') && WP_CLI) {
262
+            require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php');
263
+            WP_CLI::add_command('invoicing', 'WPInv_CLI');
264 264
         }
265 265
         
266 266
         // include css inliner
267
-        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
268
-            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
267
+        if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
268
+            include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
269 269
         }
270 270
         
271
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
271
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
272 272
     }
273 273
 
274 274
     /**
@@ -279,21 +279,21 @@  discard block
 block discarded – undo
279 279
 	 * @since       1.0.19
280 280
 	 * @return      void
281 281
 	 */
282
-	public function autoload( $class_name ) {
282
+	public function autoload($class_name) {
283 283
 
284 284
 		// Normalize the class name...
285
-		$class_name  = strtolower( $class_name );
285
+		$class_name = strtolower($class_name);
286 286
 
287 287
 		// ... and make sure it is our class.
288
-		if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) {
288
+		if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) {
289 289
 			return;
290 290
 		}
291 291
 
292 292
 		// Next, prepare the file name from the class.
293
-		$file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php';
293
+		$file_name = 'class-' . str_replace('_', '-', $class_name) . '.php';
294 294
 
295 295
         // Base path of the classes.
296
-        $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR );
296
+        $plugin_path = untrailingslashit(WPINV_PLUGIN_DIR);
297 297
 
298 298
 		// And an array of possible locations in order of importance.
299 299
 		$locations = array(
@@ -304,10 +304,10 @@  discard block
 block discarded – undo
304 304
             "$plugin_path/includes/admin/meta-boxes",
305 305
 		);
306 306
 
307
-		foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) {
307
+		foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) {
308 308
 
309
-			if ( file_exists( trailingslashit( $location ) . $file_name ) ) {
310
-				include trailingslashit( $location ) . $file_name;
309
+			if (file_exists(trailingslashit($location) . $file_name)) {
310
+				include trailingslashit($location) . $file_name;
311 311
 				break;
312 312
 			}
313 313
 
@@ -330,128 +330,128 @@  discard block
 block discarded – undo
330 330
             )
331 331
         );
332 332
 
333
-        foreach ( $gateways as $id => $class ) {
334
-            $this->gateways[ $id ] = new $class();
333
+        foreach ($gateways as $id => $class) {
334
+            $this->gateways[$id] = new $class();
335 335
         }
336 336
 
337 337
         // Fires after getpaid inits.
338
-        do_action( 'getpaid_init', $this );
338
+        do_action('getpaid_init', $this);
339 339
 
340 340
     }
341 341
     
342 342
     public function admin_init() {
343 343
         self::$instance->default_payment_form = wpinv_get_default_payment_form();
344
-        add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) );
344
+        add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php'));
345 345
     }
346 346
 
347 347
     public function activation_redirect() {
348 348
         // Bail if no activation redirect
349
-        if ( !get_transient( '_wpinv_activation_redirect' ) ) {
349
+        if (!get_transient('_wpinv_activation_redirect')) {
350 350
             return;
351 351
         }
352 352
 
353 353
         // Delete the redirect transient
354
-        delete_transient( '_wpinv_activation_redirect' );
354
+        delete_transient('_wpinv_activation_redirect');
355 355
 
356 356
         // Bail if activating from network, or bulk
357
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
357
+        if (is_network_admin() || isset($_GET['activate-multi'])) {
358 358
             return;
359 359
         }
360 360
 
361
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
361
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
362 362
         exit;
363 363
     }
364 364
     
365 365
     public function enqueue_scripts() {
366
-        $suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
366
+        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
367 367
         
368
-        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css' );
369
-        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version );
370
-        wp_enqueue_style( 'wpinv_front_style' );
368
+        $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice-front.css');
369
+        wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), $version);
370
+        wp_enqueue_style('wpinv_front_style');
371 371
                
372 372
         // Register scripts
373
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
374
-        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  filemtime( WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js' ) );
373
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
374
+        wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), filemtime(WPINV_PLUGIN_DIR . 'assets/js/invoice-front.js'));
375 375
 
376 376
         $localize                         = array();
377
-        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
378
-        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
377
+        $localize['ajax_url']             = admin_url('admin-ajax.php');
378
+        $localize['nonce']                = wp_create_nonce('wpinv-nonce');
379 379
         $localize['currency_symbol']      = wpinv_currency_symbol();
380 380
         $localize['currency_pos']         = wpinv_currency_position();
381 381
         $localize['thousand_sep']         = wpinv_thousands_separator();
382 382
         $localize['decimal_sep']          = wpinv_decimal_separator();
383 383
         $localize['decimals']             = wpinv_decimals();
384
-        $localize['txtComplete']          = __( 'Continue', 'invoicing' );
384
+        $localize['txtComplete']          = __('Continue', 'invoicing');
385 385
         $localize['UseTaxes']             = wpinv_use_taxes();
386
-        $localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
387
-        $localize['formNonce']            = wp_create_nonce( 'getpaid_form_nonce' );
388
-        $localize['connectionError']      = __( 'Could not establish a connection to the server.', 'invoicing' );
386
+        $localize['checkoutNonce']        = wp_create_nonce('wpinv_checkout_nonce');
387
+        $localize['formNonce']            = wp_create_nonce('getpaid_form_nonce');
388
+        $localize['connectionError']      = __('Could not establish a connection to the server.', 'invoicing');
389 389
 
390
-        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
390
+        $localize = apply_filters('wpinv_front_js_localize', $localize);
391 391
         
392
-        wp_enqueue_script( 'jquery-blockui' );
392
+        wp_enqueue_script('jquery-blockui');
393 393
         $autofill_api = wpinv_get_option('address_autofill_api');
394 394
         $autofill_active = wpinv_get_option('address_autofill_active');
395
-        if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
396
-            if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
397
-                wp_dequeue_script( 'google-maps-api' );
395
+        if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) {
396
+            if (wp_script_is('google-maps-api', 'enqueued')) {
397
+                wp_dequeue_script('google-maps-api');
398 398
             }
399
-            wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
400
-            wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
399
+            wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false);
400
+            wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true);
401 401
         }
402 402
 
403
-        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
404
-        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
403
+        wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
404
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
405 405
 
406
-        wp_enqueue_script( 'wpinv-front-script' );
407
-        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
406
+        wp_enqueue_script('wpinv-front-script');
407
+        wp_localize_script('wpinv-front-script', 'WPInv', $localize);
408 408
 
409
-        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' );
410
-        wp_enqueue_script( 'wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'wpinv-front-script', 'wp-hooks' ),  $version, true );
409
+        $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js');
410
+        wp_enqueue_script('wpinv-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('wpinv-front-script', 'wp-hooks'), $version, true);
411 411
     }
412 412
 
413
-    public function admin_enqueue_scripts( $hook ) {
413
+    public function admin_enqueue_scripts($hook) {
414 414
         global $post, $pagenow;
415 415
         
416 416
         $post_type  = wpinv_admin_post_type();
417
-        $suffix     = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
418
-        $page       = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : '';
417
+        $suffix     = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
418
+        $page       = isset($_GET['page']) ? strtolower($_GET['page']) : '';
419 419
 
420 420
         $jquery_ui_css = false;
421
-        if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) {
421
+        if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
422 422
             $jquery_ui_css = true;
423
-        } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) {
423
+        } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') {
424 424
             $jquery_ui_css = true;
425 425
         }
426
-        if ( $jquery_ui_css ) {
427
-            wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
428
-            wp_enqueue_style( 'jquery-ui-css' );
429
-            wp_deregister_style( 'yoast-seo-select2' );
430
-	        wp_deregister_style( 'yoast-seo-monorepo' );
426
+        if ($jquery_ui_css) {
427
+            wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16');
428
+            wp_enqueue_style('jquery-ui-css');
429
+            wp_deregister_style('yoast-seo-select2');
430
+	        wp_deregister_style('yoast-seo-monorepo');
431 431
         }
432 432
 
433
-        wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
434
-        wp_enqueue_style( 'wpinv_meta_box_style' );
433
+        wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
434
+        wp_enqueue_style('wpinv_meta_box_style');
435 435
         
436
-        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
437
-        wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version );
438
-        wp_enqueue_style( 'wpinv_admin_style' );
436
+        $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
437
+        wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), $version);
438
+        wp_enqueue_style('wpinv_admin_style');
439 439
 
440
-        $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) );
441
-        if ( $page == 'wpinv-subscriptions' ) {
442
-            wp_enqueue_script( 'jquery-ui-datepicker' );
443
-            wp_deregister_style( 'yoast-seo-select2' );
444
-	        wp_deregister_style( 'yoast-seo-monorepo' );
440
+        $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php'));
441
+        if ($page == 'wpinv-subscriptions') {
442
+            wp_enqueue_script('jquery-ui-datepicker');
443
+            wp_deregister_style('yoast-seo-select2');
444
+	        wp_deregister_style('yoast-seo-monorepo');
445 445
         }
446 446
         
447
-        if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) {
448
-            wp_enqueue_script( 'jquery-ui-datepicker' );
447
+        if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) {
448
+            wp_enqueue_script('jquery-ui-datepicker');
449 449
         }
450 450
 
451
-        wp_enqueue_style( 'wp-color-picker' );
452
-        wp_enqueue_script( 'wp-color-picker' );
451
+        wp_enqueue_style('wp-color-picker');
452
+        wp_enqueue_script('wp-color-picker');
453 453
         
454
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
454
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
455 455
 
456 456
         if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
457 457
             $autofill_api = wpinv_get_option('address_autofill_api');
@@ -462,21 +462,21 @@  discard block
 block discarded – undo
462 462
             }
463 463
         }
464 464
 
465
-        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
466
-        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
465
+        wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
466
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
467 467
 
468
-        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
469
-        wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ),  $version );
470
-        wp_enqueue_script( 'wpinv-admin-script' );
468
+        $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
469
+        wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), $version);
470
+        wp_enqueue_script('wpinv-admin-script');
471 471
         
472 472
         $localize                               = array();
473
-        $localize['ajax_url']                   = admin_url( 'admin-ajax.php' );
474
-        $localize['post_ID']                    = isset( $post->ID ) ? $post->ID : '';
475
-        $localize['wpinv_nonce']                = wp_create_nonce( 'wpinv-nonce' );
476
-        $localize['add_invoice_note_nonce']     = wp_create_nonce( 'add-invoice-note' );
477
-        $localize['delete_invoice_note_nonce']  = wp_create_nonce( 'delete-invoice-note' );
478
-        $localize['invoice_item_nonce']         = wp_create_nonce( 'invoice-item' );
479
-        $localize['billing_details_nonce']      = wp_create_nonce( 'get-billing-details' );
473
+        $localize['ajax_url']                   = admin_url('admin-ajax.php');
474
+        $localize['post_ID']                    = isset($post->ID) ? $post->ID : '';
475
+        $localize['wpinv_nonce']                = wp_create_nonce('wpinv-nonce');
476
+        $localize['add_invoice_note_nonce']     = wp_create_nonce('add-invoice-note');
477
+        $localize['delete_invoice_note_nonce']  = wp_create_nonce('delete-invoice-note');
478
+        $localize['invoice_item_nonce']         = wp_create_nonce('invoice-item');
479
+        $localize['billing_details_nonce']      = wp_create_nonce('get-billing-details');
480 480
         $localize['tax']                        = wpinv_tax_amount();
481 481
         $localize['discount']                   = wpinv_discount_amount();
482 482
         $localize['currency_symbol']            = wpinv_currency_symbol();
@@ -484,104 +484,104 @@  discard block
 block discarded – undo
484 484
         $localize['thousand_sep']               = wpinv_thousands_separator();
485 485
         $localize['decimal_sep']                = wpinv_decimal_separator();
486 486
         $localize['decimals']                   = wpinv_decimals();
487
-        $localize['save_invoice']               = __( 'Save Invoice', 'invoicing' );
488
-        $localize['status_publish']             = wpinv_status_nicename( 'publish' );
489
-        $localize['status_pending']             = wpinv_status_nicename( 'wpi-pending' );
490
-        $localize['delete_tax_rate']            = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' );
491
-        $localize['OneItemMin']                 = __( 'Invoice must contain at least one item', 'invoicing' );
492
-        $localize['DeleteInvoiceItem']          = __( 'Are you sure you wish to delete this item?', 'invoicing' );
493
-        $localize['FillBillingDetails']         = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' );
494
-        $localize['confirmCalcTotals']          = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' );
495
-        $localize['AreYouSure']                 = __( 'Are you sure?', 'invoicing' );
496
-        $localize['emptyInvoice']               = __( 'Add at least one item to save invoice!', 'invoicing' );
497
-        $localize['errDeleteItem']              = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' );
498
-        $localize['delete_subscription']        = __( 'Are you sure you want to delete this subscription?', 'invoicing' );
499
-        $localize['action_edit']                = __( 'Edit', 'invoicing' );
500
-        $localize['action_cancel']              = __( 'Cancel', 'invoicing' );
501
-        $localize['item_description']           = __( 'Item Description', 'invoicing' );
502
-        $localize['discount_description']       = __( 'Discount Description', 'invoicing' );
503
-        $localize['invoice_description']        = __( 'Invoice Description', 'invoicing' );
504
-        $localize['searching']                  = __( 'Searching', 'invoicing' );
505
-
506
-        $localize = apply_filters( 'wpinv_admin_js_localize', $localize );
507
-
508
-        wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize );
487
+        $localize['save_invoice']               = __('Save Invoice', 'invoicing');
488
+        $localize['status_publish']             = wpinv_status_nicename('publish');
489
+        $localize['status_pending']             = wpinv_status_nicename('wpi-pending');
490
+        $localize['delete_tax_rate']            = __('Are you sure you wish to delete this tax rate?', 'invoicing');
491
+        $localize['OneItemMin']                 = __('Invoice must contain at least one item', 'invoicing');
492
+        $localize['DeleteInvoiceItem']          = __('Are you sure you wish to delete this item?', 'invoicing');
493
+        $localize['FillBillingDetails']         = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing');
494
+        $localize['confirmCalcTotals']          = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing');
495
+        $localize['AreYouSure']                 = __('Are you sure?', 'invoicing');
496
+        $localize['emptyInvoice']               = __('Add at least one item to save invoice!', 'invoicing');
497
+        $localize['errDeleteItem']              = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing');
498
+        $localize['delete_subscription']        = __('Are you sure you want to delete this subscription?', 'invoicing');
499
+        $localize['action_edit']                = __('Edit', 'invoicing');
500
+        $localize['action_cancel']              = __('Cancel', 'invoicing');
501
+        $localize['item_description']           = __('Item Description', 'invoicing');
502
+        $localize['discount_description']       = __('Discount Description', 'invoicing');
503
+        $localize['invoice_description']        = __('Invoice Description', 'invoicing');
504
+        $localize['searching']                  = __('Searching', 'invoicing');
505
+
506
+        $localize = apply_filters('wpinv_admin_js_localize', $localize);
507
+
508
+        wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize);
509 509
 
510 510
         // Load payment form scripts on our admin pages only.
511
-        if ( ( $hook == 'post-new.php' || $hook == 'post.php' ) && 'wpi_payment_form' === $post->post_type ) {
511
+        if (($hook == 'post-new.php' || $hook == 'post.php') && 'wpi_payment_form' === $post->post_type) {
512 512
 
513
-            wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
514
-            wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
515
-            wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
513
+            wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION);
514
+            wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
515
+            wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
516 516
 
517
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
518
-            wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
517
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
518
+            wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version);
519 519
         
520
-            wp_localize_script( 'wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array(
520
+            wp_localize_script('wpinv-admin-payment-form-script', 'wpinvPaymentFormAdmin', array(
521 521
                 'elements'      => $this->form_elements->get_elements(),
522
-                'form_elements' => $this->form_elements->get_form_elements( $post->ID ),
522
+                'form_elements' => $this->form_elements->get_form_elements($post->ID),
523 523
                 'all_items'     => $this->form_elements->get_published_items(),
524 524
                 'currency'      => wpinv_currency_symbol(),
525 525
                 'position'      => wpinv_currency_position(),
526 526
                 'decimals'      => (int) wpinv_decimals(),
527 527
                 'thousands_sep' => wpinv_thousands_separator(),
528 528
                 'decimals_sep'  => wpinv_decimal_separator(),
529
-                'form_items'    => $this->form_elements->get_form_items( $post->ID ),
529
+                'form_items'    => $this->form_elements->get_form_items($post->ID),
530 530
                 'is_default'    => $post->ID == $this->default_payment_form,
531
-            ) );
531
+            ));
532 532
 
533
-            wp_enqueue_script( 'wpinv-admin-payment-form-script' );
533
+            wp_enqueue_script('wpinv-admin-payment-form-script');
534 534
         }
535 535
 
536
-        if ( $page == 'wpinv-subscriptions' ) {
537
-            wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
538
-            wp_enqueue_script( 'wpinv-sub-admin-script' );
536
+        if ($page == 'wpinv-subscriptions') {
537
+            wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION);
538
+            wp_enqueue_script('wpinv-sub-admin-script');
539 539
         }
540 540
 
541
-        if ( $page == 'wpinv-reports' ) {
542
-            wp_enqueue_script( 'jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array( 'jquery' ), '0.7' );
541
+        if ($page == 'wpinv-reports') {
542
+            wp_enqueue_script('jquery-flot', WPINV_PLUGIN_URL . 'assets/js/jquery.flot.min.js', array('jquery'), '0.7');
543 543
         }
544 544
 
545 545
     }
546 546
 
547
-    public function admin_body_class( $classes ) {
547
+    public function admin_body_class($classes) {
548 548
         global $pagenow, $post, $current_screen;
549 549
         
550
-        if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_payment_form' || $current_screen->post_type == 'wpi_quote' ) ) {
550
+        if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_payment_form' || $current_screen->post_type == 'wpi_quote')) {
551 551
             $classes .= ' wpinv-cpt';
552 552
         }
553 553
         
554
-        $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
554
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
555 555
 
556
-        $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false;
557
-        if ( $add_class ) {
558
-            $classes .= ' wpi-' . wpinv_sanitize_key( $page );
556
+        $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false;
557
+        if ($add_class) {
558
+            $classes .= ' wpi-' . wpinv_sanitize_key($page);
559 559
         }
560 560
         
561 561
         $settings_class = array();
562
-        if ( $page == 'wpinv-settings' ) {
563
-            if ( !empty( $_REQUEST['tab'] ) ) {
564
-                $settings_class[] = sanitize_text_field( $_REQUEST['tab'] );
562
+        if ($page == 'wpinv-settings') {
563
+            if (!empty($_REQUEST['tab'])) {
564
+                $settings_class[] = sanitize_text_field($_REQUEST['tab']);
565 565
             }
566 566
             
567
-            if ( !empty( $_REQUEST['section'] ) ) {
568
-                $settings_class[] = sanitize_text_field( $_REQUEST['section'] );
567
+            if (!empty($_REQUEST['section'])) {
568
+                $settings_class[] = sanitize_text_field($_REQUEST['section']);
569 569
             }
570 570
             
571
-            $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main';
571
+            $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main';
572 572
         }
573 573
         
574
-        if ( !empty( $settings_class ) ) {
575
-            $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) );
574
+        if (!empty($settings_class)) {
575
+            $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-'));
576 576
         }
577 577
         
578 578
         $post_type = wpinv_admin_post_type();
579 579
 
580
-        if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) {
580
+        if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) {
581 581
             return $classes .= ' wpinv';
582 582
         }
583 583
         
584
-        if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) {
584
+        if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) {
585 585
             $classes .= ' wpi-editable-n';
586 586
         }
587 587
 
@@ -593,21 +593,21 @@  discard block
 block discarded – undo
593 593
     }
594 594
     
595 595
     public function wpinv_actions() {
596
-        if ( isset( $_REQUEST['wpi_action'] ) ) {
597
-            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
596
+        if (isset($_REQUEST['wpi_action'])) {
597
+            do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
598 598
         }
599 599
     }
600 600
     
601
-    public function pre_get_posts( $wp_query ) {
602
-        if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
603
-            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
601
+    public function pre_get_posts($wp_query) {
602
+        if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
603
+            $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
604 604
         }
605 605
         
606 606
         return $wp_query;
607 607
     }
608 608
     
609 609
     public function bp_invoicing_init() {
610
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
610
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
611 611
     }
612 612
 
613 613
 	/**
@@ -615,13 +615,13 @@  discard block
 block discarded – undo
615 615
 	 *
616 616
 	 */
617 617
 	public function register_widgets() {
618
-		register_widget( "WPInv_Checkout_Widget" );
619
-		register_widget( "WPInv_History_Widget" );
620
-		register_widget( "WPInv_Receipt_Widget" );
621
-		register_widget( "WPInv_Subscriptions_Widget" );
622
-		register_widget( "WPInv_Buy_Item_Widget" );
623
-        register_widget( "WPInv_Messages_Widget" );
624
-        register_widget( 'WPInv_GetPaid_Widget' );
618
+		register_widget("WPInv_Checkout_Widget");
619
+		register_widget("WPInv_History_Widget");
620
+		register_widget("WPInv_Receipt_Widget");
621
+		register_widget("WPInv_Subscriptions_Widget");
622
+		register_widget("WPInv_Buy_Item_Widget");
623
+        register_widget("WPInv_Messages_Widget");
624
+        register_widget('WPInv_GetPaid_Widget');
625 625
 	}
626 626
     
627 627
     /**
@@ -630,10 +630,10 @@  discard block
 block discarded – undo
630 630
      * @since 1.0.19
631 631
      * @param int[] $excluded_posts_ids
632 632
      */
633
-    public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ){
633
+    public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) {
634 634
 
635 635
         // Ensure that we have an array.
636
-        if ( ! is_array( $excluded_posts_ids ) ) {
636
+        if (!is_array($excluded_posts_ids)) {
637 637
             $excluded_posts_ids = array();
638 638
         }
639 639
 
@@ -641,24 +641,24 @@  discard block
 block discarded – undo
641 641
         $our_pages = array();
642 642
     
643 643
         // Checkout page.
644
-        $our_pages[] = wpinv_get_option( 'checkout_page', false );
644
+        $our_pages[] = wpinv_get_option('checkout_page', false);
645 645
 
646 646
         // Success page.
647
-        $our_pages[] = wpinv_get_option( 'success_page', false );
647
+        $our_pages[] = wpinv_get_option('success_page', false);
648 648
 
649 649
         // Failure page.
650
-        $our_pages[] = wpinv_get_option( 'failure_page', false );
650
+        $our_pages[] = wpinv_get_option('failure_page', false);
651 651
 
652 652
         // History page.
653
-        $our_pages[] = wpinv_get_option( 'invoice_history_page', false );
653
+        $our_pages[] = wpinv_get_option('invoice_history_page', false);
654 654
 
655 655
         // Subscriptions page.
656
-        $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false );
656
+        $our_pages[] = wpinv_get_option('invoice_subscription_page', false);
657 657
 
658
-        $our_pages   = array_map( 'intval', array_filter( $our_pages ) );
658
+        $our_pages   = array_map('intval', array_filter($our_pages));
659 659
 
660 660
         $excluded_posts_ids = $excluded_posts_ids + $our_pages;
661
-        return array_unique( $excluded_posts_ids );
661
+        return array_unique($excluded_posts_ids);
662 662
 
663 663
     }
664 664
 
Please login to merge, or discard this patch.
includes/wpinv-gateway-functions.php 1 patch
Spacing   +295 added lines, -295 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
  * Returns an array of payment gateways.
@@ -13,153 +13,153 @@  discard block
 block discarded – undo
13 13
     // Default, built-in gateways
14 14
     $gateways = array(
15 15
         'authorizenet' => array(
16
-            'admin_label'    => __( 'Authorize.Net (AIM)', 'invoicing' ),
17
-            'checkout_label' => __( 'Authorize.Net - Credit Card / Debit Card', 'invoicing' ),
16
+            'admin_label'    => __('Authorize.Net (AIM)', 'invoicing'),
17
+            'checkout_label' => __('Authorize.Net - Credit Card / Debit Card', 'invoicing'),
18 18
             'ordering'       => 4,
19 19
         ),
20 20
         'bank_transfer' => array(
21
-            'admin_label'    => __( 'Pre Bank Transfer', 'invoicing' ),
22
-            'checkout_label' => __( 'Pre Bank Transfer', 'invoicing' ),
21
+            'admin_label'    => __('Pre Bank Transfer', 'invoicing'),
22
+            'checkout_label' => __('Pre Bank Transfer', 'invoicing'),
23 23
             'ordering'       => 11,
24 24
         ),
25 25
     );
26 26
 
27
-    $gateways = apply_filters( 'wpinv_payment_gateways', $gateways );
28
-    return is_array( $gateways ) ? $gateways : array();
27
+    $gateways = apply_filters('wpinv_payment_gateways', $gateways);
28
+    return is_array($gateways) ? $gateways : array();
29 29
 }
30 30
 
31
-function wpinv_payment_gateway_titles( $all_gateways ) {
31
+function wpinv_payment_gateway_titles($all_gateways) {
32 32
     global $wpinv_options;
33 33
 
34 34
     $gateways = array();
35
-    foreach ( $all_gateways as $key => $gateway ) {
36
-        if ( !empty( $wpinv_options[$key . '_title'] ) ) {
37
-            $all_gateways[$key]['checkout_label'] = __( $wpinv_options[$key . '_title'], 'invoicing' );
35
+    foreach ($all_gateways as $key => $gateway) {
36
+        if (!empty($wpinv_options[$key . '_title'])) {
37
+            $all_gateways[$key]['checkout_label'] = __($wpinv_options[$key . '_title'], 'invoicing');
38 38
         }
39 39
 
40
-        $gateways[$key] = isset( $wpinv_options[$key . '_ordering'] ) ? $wpinv_options[$key . '_ordering'] : ( isset( $gateway['ordering'] ) ? $gateway['ordering'] : '' );
40
+        $gateways[$key] = isset($wpinv_options[$key . '_ordering']) ? $wpinv_options[$key . '_ordering'] : (isset($gateway['ordering']) ? $gateway['ordering'] : '');
41 41
     }
42 42
 
43
-    asort( $gateways );
43
+    asort($gateways);
44 44
 
45
-    foreach ( $gateways as $gateway => $key ) {
45
+    foreach ($gateways as $gateway => $key) {
46 46
         $gateways[$gateway] = $all_gateways[$gateway];
47 47
     }
48 48
 
49 49
     return $gateways;
50 50
 }
51
-add_filter( 'wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1 );
51
+add_filter('wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1);
52 52
 
53
-function wpinv_get_enabled_payment_gateways( $sort = false ) {
53
+function wpinv_get_enabled_payment_gateways($sort = false) {
54 54
     $gateways = wpinv_get_payment_gateways();
55
-    $enabled  = wpinv_get_option( 'gateways', false );
55
+    $enabled  = wpinv_get_option('gateways', false);
56 56
 
57 57
     $gateway_list = array();
58 58
 
59
-    foreach ( $gateways as $key => $gateway ) {
60
-        if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) {
61
-            $gateway_list[ $key ] = $gateway;
59
+    foreach ($gateways as $key => $gateway) {
60
+        if (isset($enabled[$key]) && $enabled[$key] == 1) {
61
+            $gateway_list[$key] = $gateway;
62 62
         }
63 63
     }
64 64
 
65
-    if ( true === $sort ) {
66
-        uasort( $gateway_list, 'wpinv_sort_gateway_order' );
65
+    if (true === $sort) {
66
+        uasort($gateway_list, 'wpinv_sort_gateway_order');
67 67
         
68 68
         // Reorder our gateways so the default is first
69 69
         $default_gateway_id = wpinv_get_default_gateway();
70 70
 
71
-        if ( wpinv_is_gateway_active( $default_gateway_id ) ) {
72
-            $default_gateway    = array( $default_gateway_id => $gateway_list[ $default_gateway_id ] );
73
-            unset( $gateway_list[ $default_gateway_id ] );
71
+        if (wpinv_is_gateway_active($default_gateway_id)) {
72
+            $default_gateway = array($default_gateway_id => $gateway_list[$default_gateway_id]);
73
+            unset($gateway_list[$default_gateway_id]);
74 74
 
75
-            $gateway_list = array_merge( $default_gateway, $gateway_list );
75
+            $gateway_list = array_merge($default_gateway, $gateway_list);
76 76
         }
77 77
     }
78 78
 
79
-    return apply_filters( 'wpinv_enabled_payment_gateways', $gateway_list );
79
+    return apply_filters('wpinv_enabled_payment_gateways', $gateway_list);
80 80
 }
81 81
 
82
-function wpinv_sort_gateway_order( $a, $b ) {
82
+function wpinv_sort_gateway_order($a, $b) {
83 83
     return $a['ordering'] - $b['ordering'];
84 84
 }
85 85
 
86
-function wpinv_is_gateway_active( $gateway ) {
86
+function wpinv_is_gateway_active($gateway) {
87 87
     $gateways = wpinv_get_enabled_payment_gateways();
88 88
 
89
-    $ret = is_array($gateways) && $gateway ?  array_key_exists( $gateway, $gateways ) : false;
89
+    $ret = is_array($gateways) && $gateway ?  array_key_exists($gateway, $gateways) : false;
90 90
 
91
-    return apply_filters( 'wpinv_is_gateway_active', $ret, $gateway, $gateways );
91
+    return apply_filters('wpinv_is_gateway_active', $ret, $gateway, $gateways);
92 92
 }
93 93
 
94 94
 function wpinv_get_default_gateway() {
95
-    $default = wpinv_get_option( 'default_gateway', 'paypal' );
95
+    $default = wpinv_get_option('default_gateway', 'paypal');
96 96
 
97
-    if ( !wpinv_is_gateway_active( $default ) ) {
97
+    if (!wpinv_is_gateway_active($default)) {
98 98
         $gateways = wpinv_get_enabled_payment_gateways();
99
-        $gateways = array_keys( $gateways );
100
-        $default  = reset( $gateways );
99
+        $gateways = array_keys($gateways);
100
+        $default  = reset($gateways);
101 101
     }
102 102
 
103
-    return apply_filters( 'wpinv_default_gateway', $default );
103
+    return apply_filters('wpinv_default_gateway', $default);
104 104
 }
105 105
 
106
-function wpinv_get_gateway_admin_label( $gateway ) {
106
+function wpinv_get_gateway_admin_label($gateway) {
107 107
     $gateways = wpinv_get_payment_gateways();
108
-    $label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway;
109
-    $payment  = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false;
108
+    $label    = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway;
109
+    $payment  = isset($_GET['id']) ? absint($_GET['id']) : false;
110 110
 
111
-    if( $gateway == 'manual' && $payment ) {
112
-        if( !( (float)wpinv_payment_total( $payment ) > 0 ) ) {
113
-            $label = __( 'Free Purchase', 'invoicing' );
111
+    if ($gateway == 'manual' && $payment) {
112
+        if (!((float) wpinv_payment_total($payment) > 0)) {
113
+            $label = __('Free Purchase', 'invoicing');
114 114
         }
115 115
     }
116 116
 
117
-    return apply_filters( 'wpinv_gateway_admin_label', $label, $gateway );
117
+    return apply_filters('wpinv_gateway_admin_label', $label, $gateway);
118 118
 }
119 119
 
120
-function wpinv_get_gateway_description( $gateway ) {
120
+function wpinv_get_gateway_description($gateway) {
121 121
     global $wpinv_options;
122 122
 
123
-    $description = ! empty( $wpinv_options[$gateway . '_desc'] ) ? $wpinv_options[$gateway . '_desc'] : '';
123
+    $description = !empty($wpinv_options[$gateway . '_desc']) ? $wpinv_options[$gateway . '_desc'] : '';
124 124
 
125
-    return apply_filters( 'wpinv_gateway_description', $description, $gateway );
125
+    return apply_filters('wpinv_gateway_description', $description, $gateway);
126 126
 }
127 127
 
128
-function wpinv_get_gateway_button_label( $gateway ) {
129
-    return apply_filters( 'wpinv_gateway_' . $gateway . '_button_label', '' );
128
+function wpinv_get_gateway_button_label($gateway) {
129
+    return apply_filters('wpinv_gateway_' . $gateway . '_button_label', '');
130 130
 }
131 131
 
132
-function wpinv_get_gateway_checkout_label( $gateway ) {
132
+function wpinv_get_gateway_checkout_label($gateway) {
133 133
     $gateways = wpinv_get_payment_gateways();
134
-    $label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway;
134
+    $label    = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway;
135 135
 
136
-    if( $gateway == 'manual' ) {
137
-        $label = __( 'Manual Payment', 'invoicing' );
136
+    if ($gateway == 'manual') {
137
+        $label = __('Manual Payment', 'invoicing');
138 138
     }
139 139
 
140
-    return apply_filters( 'wpinv_gateway_checkout_label', ucfirst( $label ), $gateway );
140
+    return apply_filters('wpinv_gateway_checkout_label', ucfirst($label), $gateway);
141 141
 }
142 142
 
143
-function wpinv_settings_sections_gateways( $settings ) {
143
+function wpinv_settings_sections_gateways($settings) {
144 144
     $gateways = wpinv_get_payment_gateways();
145 145
     
146 146
     if (!empty($gateways)) {
147
-        foreach  ($gateways as $key => $gateway) {
147
+        foreach ($gateways as $key => $gateway) {
148 148
             $settings[$key] = $gateway['admin_label'];
149 149
         }
150 150
     }
151 151
     
152 152
     return $settings;    
153 153
 }
154
-add_filter( 'wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1 );
154
+add_filter('wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1);
155 155
 
156 156
 /**
157 157
  * Adds GateWay settings.
158 158
  */
159
-function wpinv_settings_gateways( $settings ) {
159
+function wpinv_settings_gateways($settings) {
160 160
 
161 161
     // Loop through each gateway.
162
-    foreach  ( wpinv_get_payment_gateways() as $key => $gateway ) {
162
+    foreach (wpinv_get_payment_gateways() as $key => $gateway) {
163 163
 
164 164
         $gateway_settings = array(
165 165
 
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
             "{$key}_header" => array(
168 168
 
169 169
                 'id'     => "{$key}_gateway_header",
170
-                'name'   => '<h3>' . wp_sprintf( __( '%s Settings', 'invoicing' ), $gateway['admin_label'] ) . '</h3>',
170
+                'name'   => '<h3>' . wp_sprintf(__('%s Settings', 'invoicing'), $gateway['admin_label']) . '</h3>',
171 171
                 'custom' => $key,
172 172
                 'type'   => 'gateway_header',
173 173
 
@@ -176,56 +176,56 @@  discard block
 block discarded – undo
176 176
             // Activate/Deactivate a gateway.
177 177
             "{$key}_active" => array(
178 178
                 'id'   => $key . '_active',
179
-                'name' => __( 'Activate', 'invoicing' ),
180
-                'desc' => wp_sprintf( __( 'Enable %s', 'invoicing' ), $gateway['admin_label'] ),
179
+                'name' => __('Activate', 'invoicing'),
180
+                'desc' => wp_sprintf(__('Enable %s', 'invoicing'), $gateway['admin_label']),
181 181
                 'type' => 'checkbox',
182 182
             ),
183 183
 
184 184
             // Activate/Deactivate sandbox.
185 185
             "{$key}_sandbox" => array(
186 186
                 'id'   => $key . '_sandbox',
187
-                'name' => __( 'Sandbox', 'invoicing' ),
188
-                'desc' => __( 'Enable sandbox to test payments', 'invoicing' ),
187
+                'name' => __('Sandbox', 'invoicing'),
188
+                'desc' => __('Enable sandbox to test payments', 'invoicing'),
189 189
                 'type' => 'checkbox',
190 190
             ),
191 191
 
192 192
             // Checkout title.
193 193
             "{$key}_title" => array(
194 194
                 'id'   => $key . '_title',
195
-                'name' => __( 'Checkout Title', 'invoicing' ),
196
-                'std'  => isset( $gateway['checkout_label'] ) ? $gateway['checkout_label'] : '',
195
+                'name' => __('Checkout Title', 'invoicing'),
196
+                'std'  => isset($gateway['checkout_label']) ? $gateway['checkout_label'] : '',
197 197
                 'type' => 'text',
198 198
             ),
199 199
 
200 200
             // Checkout description.
201 201
             "{$key}_desc" => array(
202 202
                 'id'   => $key . '_desc',
203
-                'name' => __( 'Checkout Description', 'invoicing' ),
204
-                'std'  => apply_filters( "getpaid_default_{$key}_checkout_description", '' ),
203
+                'name' => __('Checkout Description', 'invoicing'),
204
+                'std'  => apply_filters("getpaid_default_{$key}_checkout_description", ''),
205 205
                 'type' => 'text',
206 206
             ),
207 207
 
208 208
             // Checkout order.
209 209
             "{$key}_ordering" => array(
210 210
                 'id'   => $key . '_ordering',
211
-                'name' => __( 'Priority', 'invoicing' ),
212
-                'std'  => apply_filters( "getpaid_default_{$key}_checkout_description", '' ),
211
+                'name' => __('Priority', 'invoicing'),
212
+                'std'  => apply_filters("getpaid_default_{$key}_checkout_description", ''),
213 213
                 'type' => 'number',
214 214
                 'step' => '1',
215 215
                 'min'  => '-100000',
216 216
                 'max'  => '100000',
217
-                'std'  => isset( $gateway['ordering'] ) ? $gateway['ordering'] : '10',
217
+                'std'  => isset($gateway['ordering']) ? $gateway['ordering'] : '10',
218 218
             ),
219 219
 
220 220
         );
221 221
 
222 222
         // Maybe remove the sandbox.
223
-        if ( ! apply_filters( "wpinv_{$key}_supports_sandbox", false ) ) {
224
-            unset( $gateway_settings["{$key}_sandbox"] );
223
+        if (!apply_filters("wpinv_{$key}_supports_sandbox", false)) {
224
+            unset($gateway_settings["{$key}_sandbox"]);
225 225
         }
226 226
   
227
-        $gateway_settings = apply_filters( 'wpinv_gateway_settings', $gateway_settings, $key, $gateway );
228
-        $gateway_settings = apply_filters( 'wpinv_gateway_settings_' . $key, $gateway_settings, $gateway );
227
+        $gateway_settings = apply_filters('wpinv_gateway_settings', $gateway_settings, $key, $gateway);
228
+        $gateway_settings = apply_filters('wpinv_gateway_settings_' . $key, $gateway_settings, $gateway);
229 229
         
230 230
         $settings[$key] = $gateway_settings;
231 231
     }
@@ -233,38 +233,38 @@  discard block
 block discarded – undo
233 233
     return $settings;
234 234
 
235 235
 }
236
-add_filter( 'wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1 );
236
+add_filter('wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1);
237 237
 
238
-function wpinv_gateway_header_callback( $args ) {
239
-    echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr( $args['custom'] ) . '" />';
238
+function wpinv_gateway_header_callback($args) {
239
+    echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr($args['custom']) . '" />';
240 240
 }
241 241
 
242
-function wpinv_get_gateway_supports( $gateway ) {
242
+function wpinv_get_gateway_supports($gateway) {
243 243
     $gateways = wpinv_get_enabled_payment_gateways();
244
-    $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array();
245
-    return apply_filters( 'wpinv_gateway_supports', $supports, $gateway );
244
+    $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array();
245
+    return apply_filters('wpinv_gateway_supports', $supports, $gateway);
246 246
 }
247 247
 
248
-function wpinv_gateway_supports_buy_now( $gateway ) {
249
-    $supports = wpinv_get_gateway_supports( $gateway );
250
-    $ret = in_array( 'buy_now', $supports );
251
-    return apply_filters( 'wpinv_gateway_supports_buy_now', $ret, $gateway );
248
+function wpinv_gateway_supports_buy_now($gateway) {
249
+    $supports = wpinv_get_gateway_supports($gateway);
250
+    $ret = in_array('buy_now', $supports);
251
+    return apply_filters('wpinv_gateway_supports_buy_now', $ret, $gateway);
252 252
 }
253 253
 
254 254
 function wpinv_shop_supports_buy_now() {
255 255
     $gateways = wpinv_get_enabled_payment_gateways();
256 256
     $ret      = false;
257 257
 
258
-    if ( !wpinv_use_taxes()  && $gateways ) {
259
-        foreach ( $gateways as $gateway_id => $gateway ) {
260
-            if ( wpinv_gateway_supports_buy_now( $gateway_id ) ) {
258
+    if (!wpinv_use_taxes() && $gateways) {
259
+        foreach ($gateways as $gateway_id => $gateway) {
260
+            if (wpinv_gateway_supports_buy_now($gateway_id)) {
261 261
                 $ret = true;
262 262
                 break;
263 263
             }
264 264
         }
265 265
     }
266 266
 
267
-    return apply_filters( 'wpinv_shop_supports_buy_now', $ret );
267
+    return apply_filters('wpinv_shop_supports_buy_now', $ret);
268 268
 }
269 269
 
270 270
 
@@ -272,61 +272,61 @@  discard block
 block discarded – undo
272 272
     $gateways = wpinv_get_enabled_payment_gateways();
273 273
     $show_gateways = false;
274 274
 
275
-    $chosen_gateway = isset( $_GET['payment-mode'] ) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode'] ) : false;
275
+    $chosen_gateway = isset($_GET['payment-mode']) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode']) : false;
276 276
 
277
-    if ( count( $gateways ) > 1 && empty( $chosen_gateway ) ) {
277
+    if (count($gateways) > 1 && empty($chosen_gateway)) {
278 278
         $show_gateways = true;
279
-        if ( wpinv_get_cart_total() <= 0 ) {
279
+        if (wpinv_get_cart_total() <= 0) {
280 280
             $show_gateways = false;
281 281
         }
282 282
     }
283 283
     
284
-    if ( !$show_gateways && wpinv_cart_has_recurring_item() ) {
284
+    if (!$show_gateways && wpinv_cart_has_recurring_item()) {
285 285
         $show_gateways = true;
286 286
     }
287 287
 
288
-    return apply_filters( 'wpinv_show_gateways', $show_gateways );
288
+    return apply_filters('wpinv_show_gateways', $show_gateways);
289 289
 }
290 290
 
291
-function wpinv_get_chosen_gateway( $invoice_id = 0 ) {
292
-	$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
291
+function wpinv_get_chosen_gateway($invoice_id = 0) {
292
+	$gateways = array_keys(wpinv_get_enabled_payment_gateways());
293 293
 
294 294
     $chosen = false;
295
-    if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) {
295
+    if ($invoice_id > 0 && $invoice = wpinv_get_invoice($invoice_id)) {
296 296
         $chosen = $invoice->get_gateway();
297 297
     }
298 298
 
299
-	$chosen   = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen;
299
+	$chosen = isset($_REQUEST['payment-mode']) ? sanitize_text_field($_REQUEST['payment-mode']) : $chosen;
300 300
 
301
-	if ( false !== $chosen ) {
302
-		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen );
301
+	if (false !== $chosen) {
302
+		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen);
303 303
 	}
304 304
 
305
-	if ( ! empty ( $chosen ) ) {
306
-		$enabled_gateway = urldecode( $chosen );
307
-	} else if (  !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) {
305
+	if (!empty ($chosen)) {
306
+		$enabled_gateway = urldecode($chosen);
307
+	} else if (!empty($invoice) && (float) $invoice->get_subtotal() <= 0) {
308 308
 		$enabled_gateway = 'manual';
309 309
 	} else {
310 310
 		$enabled_gateway = wpinv_get_default_gateway();
311 311
 	}
312 312
     
313
-    if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) {
314
-        if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){
313
+    if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) {
314
+        if (wpinv_is_gateway_active(wpinv_get_default_gateway())) {
315 315
             $enabled_gateway = wpinv_get_default_gateway();
316
-        }else{
316
+        } else {
317 317
             $enabled_gateway = $gateways[0];
318 318
         }
319 319
 
320 320
     }
321 321
 
322
-	return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway );
322
+	return apply_filters('wpinv_chosen_gateway', $enabled_gateway);
323 323
 }
324 324
 
325
-function wpinv_record_gateway_error( $title = '', $message = '', $parent = 0 ) {
326
-    return wpinv_error_log( $message, $title );
325
+function wpinv_record_gateway_error($title = '', $message = '', $parent = 0) {
326
+    return wpinv_error_log($message, $title);
327 327
 }
328 328
 
329
-function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) {
329
+function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') {
330 330
 	$ret  = 0;
331 331
 	$args = array(
332 332
 		'meta_key'    => '_wpinv_gateway',
@@ -337,48 +337,48 @@  discard block
 block discarded – undo
337 337
 		'fields'      => 'ids'
338 338
 	);
339 339
 
340
-	$payments = new WP_Query( $args );
340
+	$payments = new WP_Query($args);
341 341
 
342
-	if( $payments )
342
+	if ($payments)
343 343
 		$ret = $payments->post_count;
344 344
 	return $ret;
345 345
 }
346 346
 
347
-function wpinv_settings_update_gateways( $input ) {
347
+function wpinv_settings_update_gateways($input) {
348 348
     global $wpinv_options;
349 349
     
350
-    if ( !empty( $input['save_gateway'] ) ) {
351
-        $gateways = wpinv_get_option( 'gateways', false );
350
+    if (!empty($input['save_gateway'])) {
351
+        $gateways = wpinv_get_option('gateways', false);
352 352
         $gateways = !empty($gateways) ? $gateways : array();
353 353
         $gateway = $input['save_gateway'];
354 354
         
355
-        if ( !empty( $input[$gateway . '_active'] ) ) {
355
+        if (!empty($input[$gateway . '_active'])) {
356 356
             $gateways[$gateway] = 1;
357 357
         } else {
358
-            if ( isset( $gateways[$gateway] ) ) {
359
-                unset( $gateways[$gateway] );
358
+            if (isset($gateways[$gateway])) {
359
+                unset($gateways[$gateway]);
360 360
             }
361 361
         }
362 362
         
363 363
         $input['gateways'] = $gateways;
364 364
     }
365 365
     
366
-    if ( !empty( $input['default_gateway'] ) ) {
366
+    if (!empty($input['default_gateway'])) {
367 367
         $gateways = wpinv_get_payment_gateways();
368 368
         
369
-        foreach ( $gateways as $key => $gateway ) {
370
-            $active   = 0;
371
-            if ( !empty( $input['gateways'] ) && !empty( $input['gateways'][$key] ) ) {
369
+        foreach ($gateways as $key => $gateway) {
370
+            $active = 0;
371
+            if (!empty($input['gateways']) && !empty($input['gateways'][$key])) {
372 372
                 $active = 1;
373 373
             }
374 374
             
375 375
             $input[$key . '_active'] = $active;
376 376
             
377
-            if ( empty( $wpinv_options[$key . '_title'] ) ) {
377
+            if (empty($wpinv_options[$key . '_title'])) {
378 378
                 $input[$key . '_title'] = $gateway['checkout_label'];
379 379
             }
380 380
             
381
-            if ( !isset( $wpinv_options[$key . '_ordering'] ) && isset( $gateway['ordering'] ) ) {
381
+            if (!isset($wpinv_options[$key . '_ordering']) && isset($gateway['ordering'])) {
382 382
                 $input[$key . '_ordering'] = $gateway['ordering'];
383 383
             }
384 384
         }
@@ -386,27 +386,27 @@  discard block
 block discarded – undo
386 386
     
387 387
     return $input;
388 388
 }
389
-add_filter( 'wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1 );
389
+add_filter('wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1);
390 390
 
391 391
 // PayPal Standard settings
392
-function wpinv_gateway_settings_paypal( $setting ) {    
393
-    $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing' );
394
-    $setting['paypal_desc']['std'] = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' );
392
+function wpinv_gateway_settings_paypal($setting) {    
393
+    $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __('( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing');
394
+    $setting['paypal_desc']['std'] = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing');
395 395
     
396 396
     $setting['paypal_sandbox'] = array(
397 397
             'type' => 'checkbox',
398 398
             'id'   => 'paypal_sandbox',
399
-            'name' => __( 'PayPal Sandbox', 'invoicing' ),
400
-            'desc' => __( 'PayPal sandbox can be used to test payments.', 'invoicing' ),
399
+            'name' => __('PayPal Sandbox', 'invoicing'),
400
+            'desc' => __('PayPal sandbox can be used to test payments.', 'invoicing'),
401 401
             'std'  => 1
402 402
         );
403 403
         
404 404
     $setting['paypal_email'] = array(
405 405
             'type' => 'text',
406 406
             'id'   => 'paypal_email',
407
-            'name' => __( 'PayPal Email', 'invoicing' ),
408
-            'desc' => __( 'Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing' ),
409
-            'std' => __( '[email protected]', 'invoicing' ),
407
+            'name' => __('PayPal Email', 'invoicing'),
408
+            'desc' => __('Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing'),
409
+            'std' => __('[email protected]', 'invoicing'),
410 410
         );
411 411
     /*
412 412
     $setting['paypal_ipn_url'] = array(
@@ -420,139 +420,139 @@  discard block
 block discarded – undo
420 420
         
421 421
     return $setting;
422 422
 }
423
-add_filter( 'wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1 );
423
+add_filter('wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1);
424 424
 
425 425
 // Pre Bank Transfer settings
426
-function wpinv_gateway_settings_bank_transfer( $setting ) {
427
-    $setting['bank_transfer_desc']['std'] = __( 'Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing' );
426
+function wpinv_gateway_settings_bank_transfer($setting) {
427
+    $setting['bank_transfer_desc']['std'] = __('Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing');
428 428
     
429 429
     $setting['bank_transfer_ac_name'] = array(
430 430
             'type' => 'text',
431 431
             'id' => 'bank_transfer_ac_name',
432
-            'name' => __( 'Account Name', 'invoicing' ),
433
-            'desc' => __( 'Enter the bank account name to which you want to transfer payment.', 'invoicing' ),
434
-            'std'  =>  __( 'Mr. John Martin', 'invoicing' ),
432
+            'name' => __('Account Name', 'invoicing'),
433
+            'desc' => __('Enter the bank account name to which you want to transfer payment.', 'invoicing'),
434
+            'std'  =>  __('Mr. John Martin', 'invoicing'),
435 435
         );
436 436
     
437 437
     $setting['bank_transfer_ac_no'] = array(
438 438
             'type' => 'text',
439 439
             'id' => 'bank_transfer_ac_no',
440
-            'name' => __( 'Account Number', 'invoicing' ),
441
-            'desc' => __( 'Enter your bank account number.', 'invoicing' ),
442
-            'std'  =>  __( 'TEST1234567890', 'invoicing' ),
440
+            'name' => __('Account Number', 'invoicing'),
441
+            'desc' => __('Enter your bank account number.', 'invoicing'),
442
+            'std'  =>  __('TEST1234567890', 'invoicing'),
443 443
         );
444 444
     
445 445
     $setting['bank_transfer_bank_name'] = array(
446 446
             'type' => 'text',
447 447
             'id'   => 'bank_transfer_bank_name',
448
-            'name' => __( 'Bank Name', 'invoicing' ),
449
-            'desc' => __( 'Enter the bank name to which you want to transfer payment.', 'invoicing' ),
450
-            'std' => __( 'ICICI Bank', 'invoicing' ),
448
+            'name' => __('Bank Name', 'invoicing'),
449
+            'desc' => __('Enter the bank name to which you want to transfer payment.', 'invoicing'),
450
+            'std' => __('ICICI Bank', 'invoicing'),
451 451
         );
452 452
     
453 453
     $setting['bank_transfer_ifsc'] = array(
454 454
             'type' => 'text',
455 455
             'id'   => 'bank_transfer_ifsc',
456
-            'name' => __( 'IFSC Code', 'invoicing' ),
457
-            'desc' => __( 'Enter your bank IFSC code.', 'invoicing' ),
458
-            'std'  =>  __( 'ICIC0001234', 'invoicing' ),
456
+            'name' => __('IFSC Code', 'invoicing'),
457
+            'desc' => __('Enter your bank IFSC code.', 'invoicing'),
458
+            'std'  =>  __('ICIC0001234', 'invoicing'),
459 459
         );
460 460
         
461 461
     $setting['bank_transfer_iban'] = array(
462 462
             'type' => 'text',
463 463
             'id'   => 'bank_transfer_iban',
464
-            'name' => __( 'IBAN', 'invoicing' ),
465
-            'desc' => __( 'Enter your International Bank Account Number(IBAN).', 'invoicing' ),
466
-            'std'  =>  __( 'GB29NWBK60161331926819', 'invoicing' ),
464
+            'name' => __('IBAN', 'invoicing'),
465
+            'desc' => __('Enter your International Bank Account Number(IBAN).', 'invoicing'),
466
+            'std'  =>  __('GB29NWBK60161331926819', 'invoicing'),
467 467
         );
468 468
         
469 469
     $setting['bank_transfer_bic'] = array(
470 470
             'type' => 'text',
471 471
             'id'   => 'bank_transfer_bic',
472
-            'name' => __( 'BIC/Swift Code', 'invoicing' ),
473
-            'std'  =>  __( 'ICICGB2L129', 'invoicing' ),
472
+            'name' => __('BIC/Swift Code', 'invoicing'),
473
+            'std'  =>  __('ICICGB2L129', 'invoicing'),
474 474
         );
475 475
 
476 476
     $setting['bank_transfer_sort_code'] = array(
477 477
         'type' => 'text',
478 478
         'id'   => 'bank_transfer_sort_code',
479
-        'name' => __( 'Sort Code', 'invoicing' ),
480
-        'std'  =>  __( '12-34-56', 'invoicing' ),
479
+        'name' => __('Sort Code', 'invoicing'),
480
+        'std'  =>  __('12-34-56', 'invoicing'),
481 481
     );
482 482
         
483 483
     $setting['bank_transfer_info'] = array(
484 484
             'id'   => 'bank_transfer_info',
485
-            'name' => __( 'Instructions', 'invoicing' ),
486
-            'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
485
+            'name' => __('Instructions', 'invoicing'),
486
+            'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'),
487 487
             'type' => 'textarea',
488
-            'std' => __( 'Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing' ),
488
+            'std' => __('Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing'),
489 489
             'cols' => 37,
490 490
             'rows' => 5
491 491
         );
492 492
         
493 493
     return $setting;
494 494
 }
495
-add_filter( 'wpinv_gateway_settings_bank_transfer', 'wpinv_gateway_settings_bank_transfer', 10, 1 );
495
+add_filter('wpinv_gateway_settings_bank_transfer', 'wpinv_gateway_settings_bank_transfer', 10, 1);
496 496
 
497 497
 // Authorize.Net settings
498
-function wpinv_gateway_settings_authorizenet( $setting ) {
499
-    $setting['authorizenet_active']['desc'] = $setting['authorizenet_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, CAD, CHF, DKK, EUR, GBP, JPY, NOK, NZD, PLN, SEK, USD, ZAR )', 'invoicing' );
500
-    $setting['authorizenet_desc']['std'] = __( 'Pay using a Authorize.Net to process Credit card / Debit card transactions.', 'invoicing' );
498
+function wpinv_gateway_settings_authorizenet($setting) {
499
+    $setting['authorizenet_active']['desc'] = $setting['authorizenet_active']['desc'] . ' ' . __('( Supported Currencies: AUD, CAD, CHF, DKK, EUR, GBP, JPY, NOK, NZD, PLN, SEK, USD, ZAR )', 'invoicing');
500
+    $setting['authorizenet_desc']['std'] = __('Pay using a Authorize.Net to process Credit card / Debit card transactions.', 'invoicing');
501 501
     
502 502
     $setting['authorizenet_sandbox'] = array(
503 503
             'type' => 'checkbox',
504 504
             'id'   => 'authorizenet_sandbox',
505
-            'name' => __( 'Authorize.Net Test Mode', 'invoicing' ),
506
-            'desc' => __( 'Enable Authorize.Net test mode to test payments.', 'invoicing' ),
505
+            'name' => __('Authorize.Net Test Mode', 'invoicing'),
506
+            'desc' => __('Enable Authorize.Net test mode to test payments.', 'invoicing'),
507 507
             'std'  => 1
508 508
         );
509 509
         
510 510
     $setting['authorizenet_login_id'] = array(
511 511
             'type' => 'text',
512 512
             'id'   => 'authorizenet_login_id',
513
-            'name' => __( 'API Login ID', 'invoicing' ),
514
-            'desc' => __( 'API Login ID can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 2j4rBekUnD', 'invoicing' ),
513
+            'name' => __('API Login ID', 'invoicing'),
514
+            'desc' => __('API Login ID can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 2j4rBekUnD', 'invoicing'),
515 515
             'std' => '2j4rBekUnD',
516 516
         );
517 517
     
518 518
     $setting['authorizenet_transaction_key'] = array(
519 519
             'type' => 'text',
520 520
             'id'   => 'authorizenet_transaction_key',
521
-            'name' => __( 'Transaction Key', 'invoicing' ),
522
-            'desc' => __( 'Transaction Key can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 4vyBUOJgR74679xa', 'invoicing' ),
521
+            'name' => __('Transaction Key', 'invoicing'),
522
+            'desc' => __('Transaction Key can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 4vyBUOJgR74679xa', 'invoicing'),
523 523
             'std' => '4vyBUOJgR74679xa',
524 524
         );
525 525
         
526 526
     $setting['authorizenet_md5_hash'] = array(
527 527
             'type' => 'text',
528 528
             'id'   => 'authorizenet_md5_hash',
529
-            'name' => __( 'MD5-Hash', 'invoicing' ),
530
-            'desc' => __( 'The MD5 Hash security feature allows to authenticate transaction responses from the Authorize.Net for recurring payments. It can be obtained from Authorize.Net Account > Settings > Security Settings > General Settings > MD5 Hash.', 'invoicing' ),
529
+            'name' => __('MD5-Hash', 'invoicing'),
530
+            'desc' => __('The MD5 Hash security feature allows to authenticate transaction responses from the Authorize.Net for recurring payments. It can be obtained from Authorize.Net Account > Settings > Security Settings > General Settings > MD5 Hash.', 'invoicing'),
531 531
             'std' => '',
532 532
         );
533 533
 
534 534
     $setting['authorizenet_transaction_type'] = array(
535 535
         'id'          => 'authorizenet_transaction_type',
536
-        'name'        => __( 'Transaction Type', 'invoicing' ),
537
-        'desc'        => __( 'Choose transaction type.', 'invoicing' ),
536
+        'name'        => __('Transaction Type', 'invoicing'),
537
+        'desc'        => __('Choose transaction type.', 'invoicing'),
538 538
         'type'        => 'select',
539 539
         'class'       => 'wpi_select2',
540 540
         'options'     => array(
541
-            'authorize_capture' => __( 'Authorize And Capture', 'invoicing' ),
542
-            'authorize_only' => __( 'Authorize Only', 'invoicing' ),
541
+            'authorize_capture' => __('Authorize And Capture', 'invoicing'),
542
+            'authorize_only' => __('Authorize Only', 'invoicing'),
543 543
         ),
544 544
         'std'         => 'authorize_capture'
545 545
     );
546 546
 
547 547
     $setting['authorizenet_transaction_type_recurring'] = array(
548 548
         'id'          => 'authorizenet_transaction_type_recurring',
549
-        'name'        => __( 'Transaction Type for Recurring', 'invoicing' ),
550
-        'desc'        => __( 'Choose transaction type for recurring payments.', 'invoicing' ),
549
+        'name'        => __('Transaction Type for Recurring', 'invoicing'),
550
+        'desc'        => __('Choose transaction type for recurring payments.', 'invoicing'),
551 551
         'type'        => 'select',
552 552
         'class'       => 'wpi_select2',
553 553
         'options'     => array(
554
-            'authorize_capture' => __( 'Authorize And Capture', 'invoicing' ),
555
-            'authorize_only' => __( 'Authorize Only', 'invoicing' ),
554
+            'authorize_capture' => __('Authorize And Capture', 'invoicing'),
555
+            'authorize_only' => __('Authorize Only', 'invoicing'),
556 556
         ),
557 557
         'std'         => 'authorize_only'
558 558
     );
@@ -560,9 +560,9 @@  discard block
 block discarded – undo
560 560
     $setting['authorizenet_ipn_url'] = array(
561 561
             'type' => 'ipn_url',
562 562
             'id'   => 'authorizenet_ipn_url',
563
-            'name' => __( 'Silent Post URL', 'invoicing' ),
564
-            'std' => wpinv_get_ipn_url( 'authorizenet' ),
565
-            'desc' => __( 'If you are accepting recurring payments then you must set this url at Authorize.Net Account > Settings > Transaction Format Settings > Transaction Response Settings > Silent Post URL.', 'invoicing' ),
563
+            'name' => __('Silent Post URL', 'invoicing'),
564
+            'std' => wpinv_get_ipn_url('authorizenet'),
565
+            'desc' => __('If you are accepting recurring payments then you must set this url at Authorize.Net Account > Settings > Transaction Format Settings > Transaction Response Settings > Silent Post URL.', 'invoicing'),
566 566
             'size' => 'large',
567 567
             'custom' => 'authorizenet',
568 568
             'readonly' => true
@@ -570,99 +570,99 @@  discard block
 block discarded – undo
570 570
         
571 571
     return $setting;
572 572
 }
573
-add_filter( 'wpinv_gateway_settings_authorizenet', 'wpinv_gateway_settings_authorizenet', 10, 1 );
573
+add_filter('wpinv_gateway_settings_authorizenet', 'wpinv_gateway_settings_authorizenet', 10, 1);
574 574
 
575
-function wpinv_ipn_url_callback( $args ) {    
576
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
575
+function wpinv_ipn_url_callback($args) {    
576
+    $sanitize_id = wpinv_sanitize_key($args['id']);
577 577
     
578 578
     $attrs = $args['readonly'] ? ' readonly' : '';
579 579
 
580
-    $html = '<input style="background-color:#fefefe" type="text" ' . $attrs . ' value="' . esc_attr( $args['std'] ) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" class="large-text">';
581
-    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">'  . $args['desc'] . '</label>';
580
+    $html = '<input style="background-color:#fefefe" type="text" ' . $attrs . ' value="' . esc_attr($args['std']) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" class="large-text">';
581
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>';
582 582
 
583 583
     echo $html;
584 584
 }
585 585
 
586
-function wpinv_is_test_mode( $gateway = '' ) {
587
-    if ( empty( $gateway ) ) {
586
+function wpinv_is_test_mode($gateway = '') {
587
+    if (empty($gateway)) {
588 588
         return false;
589 589
     }
590 590
     
591
-    $is_test_mode = wpinv_get_option( $gateway . '_sandbox', false );
591
+    $is_test_mode = wpinv_get_option($gateway . '_sandbox', false);
592 592
     
593
-    return apply_filters( 'wpinv_is_test_mode', $is_test_mode, $gateway );
593
+    return apply_filters('wpinv_is_test_mode', $is_test_mode, $gateway);
594 594
 }
595 595
 
596
-function wpinv_get_ipn_url( $gateway = '', $args = array() ) {
597
-    $data = array( 'wpi-listener' => 'IPN' );
596
+function wpinv_get_ipn_url($gateway = '', $args = array()) {
597
+    $data = array('wpi-listener' => 'IPN');
598 598
     
599
-    if ( !empty( $gateway ) ) {
600
-        $data['wpi-gateway'] = wpinv_sanitize_key( $gateway );
599
+    if (!empty($gateway)) {
600
+        $data['wpi-gateway'] = wpinv_sanitize_key($gateway);
601 601
     }
602 602
     
603
-    $args = !empty( $args ) && is_array( $args ) ? array_merge( $data, $args ) : $data;
603
+    $args = !empty($args) && is_array($args) ? array_merge($data, $args) : $data;
604 604
     
605
-    $ipn_url = add_query_arg( $args,  home_url( 'index.php' ) );
605
+    $ipn_url = add_query_arg($args, home_url('index.php'));
606 606
     
607
-    return apply_filters( 'wpinv_ipn_url', $ipn_url );
607
+    return apply_filters('wpinv_ipn_url', $ipn_url);
608 608
 }
609 609
 
610 610
 function wpinv_listen_for_payment_ipn() {
611 611
     // Regular PayPal IPN
612
-    if ( isset( $_GET['wpi-listener'] ) && $_GET['wpi-listener'] == 'IPN' ) {
613
-        do_action( 'wpinv_verify_payment_ipn' );
612
+    if (isset($_GET['wpi-listener']) && $_GET['wpi-listener'] == 'IPN') {
613
+        do_action('wpinv_verify_payment_ipn');
614 614
         
615
-        if ( !empty( $_GET['wpi-gateway'] ) ) {
616
-            wpinv_error_log( sanitize_text_field( $_GET['wpi-gateway'] ), 'WP Invoicing IPN', __FILE__, __LINE__ );
617
-            do_action( 'wpinv_verify_' . sanitize_text_field( $_GET['wpi-gateway'] ) . '_ipn' );
615
+        if (!empty($_GET['wpi-gateway'])) {
616
+            wpinv_error_log(sanitize_text_field($_GET['wpi-gateway']), 'WP Invoicing IPN', __FILE__, __LINE__);
617
+            do_action('wpinv_verify_' . sanitize_text_field($_GET['wpi-gateway']) . '_ipn');
618 618
         }
619 619
     }
620 620
 }
621
-add_action( 'init', 'wpinv_listen_for_payment_ipn' );
621
+add_action('init', 'wpinv_listen_for_payment_ipn');
622 622
 
623 623
 function wpinv_get_bank_instructions() {
624
-    $bank_instructions = wpinv_get_option( 'bank_transfer_info' );
624
+    $bank_instructions = wpinv_get_option('bank_transfer_info');
625 625
     
626
-    return apply_filters( 'wpinv_bank_instructions', $bank_instructions );
626
+    return apply_filters('wpinv_bank_instructions', $bank_instructions);
627 627
 }
628 628
 
629
-function wpinv_get_bank_info( $filtered = false ) {
629
+function wpinv_get_bank_info($filtered = false) {
630 630
     $bank_fields = array(
631
-        'bank_transfer_ac_name'     => __( 'Account Name', 'invoicing' ),
632
-        'bank_transfer_ac_no'       => __( 'Account Number', 'invoicing' ),
633
-        'bank_transfer_bank_name'   => __( 'Bank Name', 'invoicing' ),
634
-        'bank_transfer_ifsc'        => __( 'IFSC code', 'invoicing' ),
635
-        'bank_transfer_iban'        => __( 'IBAN', 'invoicing' ),
636
-        'bank_transfer_bic'         => __( 'BIC/Swift code', 'invoicing' ),
637
-        'bank_transfer_sort_code'   => __( 'Sort Code', 'invoicing' )
631
+        'bank_transfer_ac_name'     => __('Account Name', 'invoicing'),
632
+        'bank_transfer_ac_no'       => __('Account Number', 'invoicing'),
633
+        'bank_transfer_bank_name'   => __('Bank Name', 'invoicing'),
634
+        'bank_transfer_ifsc'        => __('IFSC code', 'invoicing'),
635
+        'bank_transfer_iban'        => __('IBAN', 'invoicing'),
636
+        'bank_transfer_bic'         => __('BIC/Swift code', 'invoicing'),
637
+        'bank_transfer_sort_code'   => __('Sort Code', 'invoicing')
638 638
     );
639 639
     
640 640
     $bank_info = array();
641
-    foreach ( $bank_fields as $field => $label ) {
642
-        if ( $filtered && !( $value = wpinv_get_option( $field ) ) ) {
641
+    foreach ($bank_fields as $field => $label) {
642
+        if ($filtered && !($value = wpinv_get_option($field))) {
643 643
             continue;
644 644
         }
645 645
         
646
-        $bank_info[$field] = array( 'label' => $label, 'value' => $value );
646
+        $bank_info[$field] = array('label' => $label, 'value' => $value);
647 647
     }
648 648
     
649
-    return apply_filters( 'wpinv_bank_info', $bank_info, $filtered );
649
+    return apply_filters('wpinv_bank_info', $bank_info, $filtered);
650 650
 }
651 651
 
652
-function wpinv_get_post_data( $method = 'request' ) {
652
+function wpinv_get_post_data($method = 'request') {
653 653
     $data       = array();
654 654
     $request    = $_REQUEST;
655 655
     
656
-    if ( $method == 'post' ) {
657
-        if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) {
656
+    if ($method == 'post') {
657
+        if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
658 658
             return $data;
659 659
         }
660 660
         
661 661
         $request = $_POST;
662 662
     }
663 663
     
664
-    if ( $method == 'get' ) {
665
-        if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'GET' ) {
664
+    if ($method == 'get') {
665
+        if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'GET') {
666 666
             return $data;
667 667
         }
668 668
         
@@ -673,11 +673,11 @@  discard block
 block discarded – undo
673 673
     $post_data = '';
674 674
     
675 675
     // Fallback just in case post_max_size is lower than needed
676
-    if ( ini_get( 'allow_url_fopen' ) ) {
677
-        $post_data = file_get_contents( 'php://input' );
676
+    if (ini_get('allow_url_fopen')) {
677
+        $post_data = file_get_contents('php://input');
678 678
     } else {
679 679
         // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough
680
-        ini_set( 'post_max_size', '12M' );
680
+        ini_set('post_max_size', '12M');
681 681
     }
682 682
     // Start the encoded data collection with notification command
683 683
     $encoded_data = 'cmd=_notify-validate';
@@ -686,33 +686,33 @@  discard block
 block discarded – undo
686 686
     $arg_separator = wpinv_get_php_arg_separator_output();
687 687
 
688 688
     // Verify there is a post_data
689
-    if ( $post_data || strlen( $post_data ) > 0 ) {
689
+    if ($post_data || strlen($post_data) > 0) {
690 690
         // Append the data
691 691
         $encoded_data .= $arg_separator . $post_data;
692 692
     } else {
693 693
         // Check if POST is empty
694
-        if ( empty( $request ) ) {
694
+        if (empty($request)) {
695 695
             // Nothing to do
696 696
             return;
697 697
         } else {
698 698
             // Loop through each POST
699
-            foreach ( $request as $key => $value ) {
699
+            foreach ($request as $key => $value) {
700 700
                 // Encode the value and append the data
701
-                $encoded_data .= $arg_separator . "$key=" . urlencode( $value );
701
+                $encoded_data .= $arg_separator . "$key=" . urlencode($value);
702 702
             }
703 703
         }
704 704
     }
705 705
 
706 706
     // Convert collected post data to an array
707
-    wp_parse_str( $encoded_data, $data );
707
+    wp_parse_str($encoded_data, $data);
708 708
 
709
-    foreach ( $data as $key => $value ) {
710
-        if ( false !== strpos( $key, 'amp;' ) ) {
711
-            $new_key = str_replace( '&amp;', '&', $key );
712
-            $new_key = str_replace( 'amp;', '&' , $new_key );
709
+    foreach ($data as $key => $value) {
710
+        if (false !== strpos($key, 'amp;')) {
711
+            $new_key = str_replace('&amp;', '&', $key);
712
+            $new_key = str_replace('amp;', '&', $new_key);
713 713
 
714
-            unset( $data[ $key ] );
715
-            $data[ $new_key ] = sanitize_text_field( $value );
714
+            unset($data[$key]);
715
+            $data[$new_key] = sanitize_text_field($value);
716 716
         }
717 717
     }
718 718
     
@@ -722,12 +722,12 @@  discard block
 block discarded – undo
722 722
 /**
723 723
  * Checks if a given gateway supports subscription payments.
724 724
  */
725
-function wpinv_gateway_support_subscription( $gateway ) {
725
+function wpinv_gateway_support_subscription($gateway) {
726 726
     $supports = false;
727 727
 
728
-    if ( wpinv_is_gateway_active( $gateway ) ) {
729
-        $supports = apply_filters( 'wpinv_' . $gateway . '_support_subscription', $supports );
730
-        $supports = apply_filters( 'getapid_gateway_supports_subscription', $supports, $gateway );
728
+    if (wpinv_is_gateway_active($gateway)) {
729
+        $supports = apply_filters('wpinv_' . $gateway . '_support_subscription', $supports);
730
+        $supports = apply_filters('getapid_gateway_supports_subscription', $supports, $gateway);
731 731
     }
732 732
 
733 733
     return $supports;
@@ -739,14 +739,14 @@  discard block
 block discarded – undo
739 739
  * @param array $gateways an array of gateways.
740 740
  * @param GetPaid_Payment_Form $form payment form.
741 741
  */
742
-function wpinv_payment_gateways_on_cart( $gateways, $form ) {
742
+function wpinv_payment_gateways_on_cart($gateways, $form) {
743 743
 
744
-    if ( $form->is_recurring() ) {
744
+    if ($form->is_recurring()) {
745 745
 
746
-        foreach ( array_keys( $gateways ) as $gateway ) {
746
+        foreach (array_keys($gateways) as $gateway) {
747 747
 
748
-            if ( ! wpinv_gateway_support_subscription( $gateway ) ) {
749
-                unset( $gateways[$gateway] );
748
+            if (!wpinv_gateway_support_subscription($gateway)) {
749
+                unset($gateways[$gateway]);
750 750
             }
751 751
 
752 752
         }
@@ -755,24 +755,24 @@  discard block
 block discarded – undo
755 755
 
756 756
     return $gateways;
757 757
 }
758
-add_filter( 'getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2 );
758
+add_filter('getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2);
759 759
 
760 760
 /**
761 761
  * Validates checkout fields.
762 762
  *
763 763
  * @param GetPaid_Payment_Form_Submission $submission
764 764
  */
765
-function wpinv_checkout_validate_gateway( $submission ) {
765
+function wpinv_checkout_validate_gateway($submission) {
766 766
 
767 767
     $data = $submission->get_data();
768 768
 
769 769
     // Non-recurring gateways should not be allowed to process recurring invoices.
770
-    if ( $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) {
771
-        wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway does not support subscription payment.', 'invoicing' ) );
770
+    if ($submission->has_recurring && !wpinv_gateway_support_subscription($data['wpi-gateway'])) {
771
+        wpinv_set_error('invalid_gateway', __('The selected payment gateway does not support subscription payment.', 'invoicing'));
772 772
     }
773 773
 
774
-    if ( ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) {
775
-        wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not active', 'invoicing' ) );
774
+    if (!wpinv_is_gateway_active($data['wpi-gateway'])) {
775
+        wpinv_set_error('invalid_gateway', __('The selected payment gateway is not active', 'invoicing'));
776 776
     }
777 777
 
778 778
 }
@@ -780,84 +780,84 @@  discard block
 block discarded – undo
780 780
 /**
781 781
  * Validates a zip code.
782 782
  */
783
-function wpinv_checkout_validate_cc_zip( $zip = 0, $country_code = '' ) {
783
+function wpinv_checkout_validate_cc_zip($zip = 0, $country_code = '') {
784 784
 
785
-    if ( empty( $zip ) || empty( $country_code ) ){
785
+    if (empty($zip) || empty($country_code)) {
786 786
         return false;
787 787
     }
788 788
 
789 789
     // Prepare the country code.
790
-    $country_code = strtoupper( trim( $country_code ) );
790
+    $country_code = strtoupper(trim($country_code));
791 791
 
792 792
     // Fetch the regexes.
793
-    $zip_regex = wpinv_get_data( 'zip-regexes' );
793
+    $zip_regex = wpinv_get_data('zip-regexes');
794 794
 
795 795
     // Check if it is valid.
796
-    $is_valid = ! isset ( $zip_regex[ $country_code ] ) || preg_match( "/" . $zip_regex[ $country_code ] . "/i", $zip );
796
+    $is_valid = !isset ($zip_regex[$country_code]) || preg_match("/" . $zip_regex[$country_code] . "/i", $zip);
797 797
 
798
-    return apply_filters( 'wpinv_is_zip_valid', $is_valid, $zip, $country_code );
798
+    return apply_filters('wpinv_is_zip_valid', $is_valid, $zip, $country_code);
799 799
 }
800 800
 
801 801
 function wpinv_checkout_validate_agree_to_terms() {
802 802
     // Validate agree to terms
803
-    if ( ! isset( $_POST['wpi_agree_to_terms'] ) || $_POST['wpi_agree_to_terms'] != 1 ) {
803
+    if (!isset($_POST['wpi_agree_to_terms']) || $_POST['wpi_agree_to_terms'] != 1) {
804 804
         // User did not agree
805
-        wpinv_set_error( 'agree_to_terms', apply_filters( 'wpinv_agree_to_terms_text', __( 'You must agree to the terms of use', 'invoicing' ) ) );
805
+        wpinv_set_error('agree_to_terms', apply_filters('wpinv_agree_to_terms_text', __('You must agree to the terms of use', 'invoicing')));
806 806
     }
807 807
 }
808 808
 
809 809
 function wpinv_checkout_validate_invoice_user() {
810 810
     global $wpi_cart, $user_ID;
811 811
 
812
-    if(empty($wpi_cart)){
812
+    if (empty($wpi_cart)) {
813 813
         $wpi_cart = wpinv_get_invoice_cart();
814 814
     }
815 815
 
816
-    $invoice_user = (int)$wpi_cart->get_user_id();
816
+    $invoice_user = (int) $wpi_cart->get_user_id();
817 817
     $valid_user_data = array(
818 818
         'user_id' => $invoice_user
819 819
     );
820 820
 
821 821
     // If guest checkout allowed
822
-    if ( !wpinv_require_login_to_checkout() ) {
822
+    if (!wpinv_require_login_to_checkout()) {
823 823
         return $valid_user_data;
824 824
     }
825 825
     
826 826
     // Verify there is a user_ID
827
-    if ( $user_ID == $invoice_user ) {
827
+    if ($user_ID == $invoice_user) {
828 828
         // Get the logged in user data
829
-        $user_data = get_userdata( $user_ID );
830
-        $required_fields  = wpinv_checkout_required_fields();
829
+        $user_data = get_userdata($user_ID);
830
+        $required_fields = wpinv_checkout_required_fields();
831 831
 
832 832
         // Loop through required fields and show error messages
833
-         if ( !empty( $required_fields ) ) {
834
-            foreach ( $required_fields as $field_name => $value ) {
835
-                if ( in_array( $value, $required_fields ) && empty( $_POST[ 'wpinv_' . $field_name ] ) ) {
836
-                    wpinv_set_error( $value['error_id'], $value['error_message'] );
833
+         if (!empty($required_fields)) {
834
+            foreach ($required_fields as $field_name => $value) {
835
+                if (in_array($value, $required_fields) && empty($_POST['wpinv_' . $field_name])) {
836
+                    wpinv_set_error($value['error_id'], $value['error_message']);
837 837
                 }
838 838
             }
839 839
         }
840 840
 
841 841
         // Verify data
842
-        if ( $user_data ) {
842
+        if ($user_data) {
843 843
             // Collected logged in user data
844 844
             $valid_user_data = array(
845 845
                 'user_id'     => $user_ID,
846
-                'email'       => isset( $_POST['wpinv_email'] ) ? sanitize_email( $_POST['wpinv_email'] ) : $user_data->user_email,
847
-                'first_name'  => isset( $_POST['wpinv_first_name'] ) && ! empty( $_POST['wpinv_first_name'] ) ? sanitize_text_field( $_POST['wpinv_first_name'] ) : $user_data->first_name,
848
-                'last_name'   => isset( $_POST['wpinv_last_name'] ) && ! empty( $_POST['wpinv_last_name']  ) ? sanitize_text_field( $_POST['wpinv_last_name']  ) : $user_data->last_name,
846
+                'email'       => isset($_POST['wpinv_email']) ? sanitize_email($_POST['wpinv_email']) : $user_data->user_email,
847
+                'first_name'  => isset($_POST['wpinv_first_name']) && !empty($_POST['wpinv_first_name']) ? sanitize_text_field($_POST['wpinv_first_name']) : $user_data->first_name,
848
+                'last_name'   => isset($_POST['wpinv_last_name']) && !empty($_POST['wpinv_last_name']) ? sanitize_text_field($_POST['wpinv_last_name']) : $user_data->last_name,
849 849
             );
850 850
 
851
-            if ( !empty( $_POST[ 'wpinv_email' ] ) && !is_email( $_POST[ 'wpinv_email' ] ) ) {
852
-                wpinv_set_error( 'invalid_email', __( 'Please enter a valid email address', 'invoicing' ) );
851
+            if (!empty($_POST['wpinv_email']) && !is_email($_POST['wpinv_email'])) {
852
+                wpinv_set_error('invalid_email', __('Please enter a valid email address', 'invoicing'));
853 853
             }
854 854
         } else {
855 855
             // Set invalid user error
856
-            wpinv_set_error( 'invalid_user', __( 'The user billing information is invalid', 'invoicing' ) );
856
+            wpinv_set_error('invalid_user', __('The user billing information is invalid', 'invoicing'));
857 857
         }
858 858
     } else {
859 859
         // Set invalid user error
860
-        wpinv_set_error( 'invalid_user_id', __( 'The invalid invoice user id', 'invoicing' ) );
860
+        wpinv_set_error('invalid_user_id', __('The invalid invoice user id', 'invoicing'));
861 861
     }
862 862
 
863 863
     // Return user data
@@ -869,18 +869,18 @@  discard block
 block discarded – undo
869 869
 
870 870
     $data = array();
871 871
     
872
-    if ( is_user_logged_in() ) {
873
-        if ( !wpinv_require_login_to_checkout() || ( wpinv_require_login_to_checkout() && (int)$wpi_cart->get_user_id() === (int)get_current_user_id() ) ) {
874
-            $data['user_id'] = (int)get_current_user_id();
872
+    if (is_user_logged_in()) {
873
+        if (!wpinv_require_login_to_checkout() || (wpinv_require_login_to_checkout() && (int) $wpi_cart->get_user_id() === (int) get_current_user_id())) {
874
+            $data['user_id'] = (int) get_current_user_id();
875 875
         } else {
876
-            wpinv_set_error( 'logged_in_only', __( 'You are not allowed to pay for this invoice', 'invoicing' ) );
876
+            wpinv_set_error('logged_in_only', __('You are not allowed to pay for this invoice', 'invoicing'));
877 877
         }
878 878
     } else {
879 879
         // If guest checkout allowed
880
-        if ( !wpinv_require_login_to_checkout() ) {
880
+        if (!wpinv_require_login_to_checkout()) {
881 881
             $data['user_id'] = 0;
882 882
         } else {
883
-            wpinv_set_error( 'logged_in_only', __( 'You must be logged in to pay for this invoice', 'invoicing' ) );
883
+            wpinv_set_error('logged_in_only', __('You must be logged in to pay for this invoice', 'invoicing'));
884 884
         }
885 885
     }
886 886
 
@@ -894,41 +894,41 @@  discard block
 block discarded – undo
894 894
  * @param WPInv_Invoice $invoice
895 895
  * @param GetPaid_Payment_Form_Submission $submission
896 896
  */
897
-function wpinv_process_checkout( $invoice, $submission ) {
897
+function wpinv_process_checkout($invoice, $submission) {
898 898
 
899 899
     // No need to send free invoices to the gateway.
900
-    if ( $invoice->is_free() ) {
901
-        $invoice->set_gateway( 'none' );
902
-        $invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true );
900
+    if ($invoice->is_free()) {
901
+        $invoice->set_gateway('none');
902
+        $invoice->add_note(__("This is a free invoice and won't be sent to the payment gateway", 'invoicing'), false, false, true);
903 903
         $invoice->mark_paid();
904
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
904
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
905 905
     }
906 906
 
907 907
     // Clear an checkout errors.
908 908
     wpinv_clear_errors();
909 909
 
910 910
     // Fires before sending to the gateway.
911
-    do_action( 'getpaid_checkout_before_gateway', $invoice, $submission );
911
+    do_action('getpaid_checkout_before_gateway', $invoice, $submission);
912 912
 
913 913
     // Allow the sumission data to be modified before it is sent to the gateway.
914 914
     $submission_data    = $submission->get_data();
915
-    $submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $submission_data['wpi-gateway'], $submission, $invoice );
916
-    $submission_data    = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice );
915
+    $submission_gateway = apply_filters('getpaid_gateway_submission_gateway', $submission_data['wpi-gateway'], $submission, $invoice);
916
+    $submission_data    = apply_filters('getpaid_gateway_submission_data', $submission_data, $submission, $invoice);
917 917
 
918 918
     // Validate the currency.
919
-    if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) {
920
-        wpinv_set_error( 'invalid_currency', __( 'The chosen payment gateway does not support the invoice currency', 'invoicing' ) );
919
+    if (!apply_filters("getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency())) {
920
+        wpinv_set_error('invalid_currency', __('The chosen payment gateway does not support the invoice currency', 'invoicing'));
921 921
     }
922 922
 
923 923
     // Check to see if we have any errors.
924
-    if ( wpinv_get_errors() ) {
924
+    if (wpinv_get_errors()) {
925 925
         wpinv_send_back_to_checkout();
926 926
     }
927 927
 
928 928
     // Send info to the gateway for payment processing
929
-    do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission );
929
+    do_action("getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission);
930 930
 
931 931
     // Backwards compatibility.
932
-    do_action( "wpinv_gateway_$submission_gateway", null, $invoice, $submission_data, $submission );
932
+    do_action("wpinv_gateway_$submission_gateway", null, $invoice, $submission_data, $submission);
933 933
 
934 934
 }
Please login to merge, or discard this patch.