Passed
Push — master ( efc474...584850 )
by Brian
04:36
created
invoicing.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,16 +19,16 @@  discard block
 block discarded – undo
19 19
 
20 20
 // Define constants.
21 21
 if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) {
22
-	define( 'WPINV_PLUGIN_FILE', __FILE__ );
22
+    define( 'WPINV_PLUGIN_FILE', __FILE__ );
23 23
 }
24 24
 
25 25
 if ( ! defined( 'WPINV_VERSION' ) ) {
26
-	define( 'WPINV_VERSION', '2.1.0' );
26
+    define( 'WPINV_VERSION', '2.1.0' );
27 27
 }
28 28
 
29 29
 // Include the main Invoicing class.
30 30
 if ( ! class_exists( 'WPInv_Plugin', false ) ) {
31
-	require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php';
31
+    require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php';
32 32
 }
33 33
 
34 34
 /**
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         $GLOBALS['invoicing'] = new WPInv_Plugin();
44 44
     }
45 45
 
46
-	return $GLOBALS['invoicing'];
46
+    return $GLOBALS['invoicing'];
47 47
 }
48 48
 
49 49
 /**
Please login to merge, or discard this patch.
includes/payments/class-getpaid-form-item.php 1 patch
Indentation   +356 added lines, -356 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,60 +10,60 @@  discard block
 block discarded – undo
10 10
 class GetPaid_Form_Item  extends WPInv_Item {
11 11
 
12 12
     /**
13
-	 * Stores a custom description for the item.
14
-	 *
15
-	 * @var string
16
-	 */
17
-	protected $custom_description = null;
18
-
19
-	/**
20
-	 * Stores the item quantity.
21
-	 *
22
-	 * @var float
23
-	 */
24
-	protected $quantity = 1;
25
-
26
-	/**
27
-	 * Stores the item meta.
28
-	 *
29
-	 * @var array
30
-	 */
31
-	protected $meta = array();
32
-
33
-	/**
34
-	 * Is this item required?
35
-	 *
36
-	 * @var int
37
-	 */
38
-	protected $is_required = true;
39
-
40
-	/**
41
-	 * Are quantities allowed?
42
-	 *
43
-	 * @var int
44
-	 */
45
-	protected $allow_quantities = false;
46
-
47
-	/**
48
-	 * Associated invoice.
49
-	 *
50
-	 * @var int
51
-	 */
52
-	public $invoice_id = 0;
53
-
54
-	/**
55
-	 * Item discount.
56
-	 *
57
-	 * @var float
58
-	 */
59
-	public $item_discount = 0;
60
-
61
-	/**
62
-	 * Item tax.
63
-	 *
64
-	 * @var float
65
-	 */
66
-	public $item_tax = 0;
13
+     * Stores a custom description for the item.
14
+     *
15
+     * @var string
16
+     */
17
+    protected $custom_description = null;
18
+
19
+    /**
20
+     * Stores the item quantity.
21
+     *
22
+     * @var float
23
+     */
24
+    protected $quantity = 1;
25
+
26
+    /**
27
+     * Stores the item meta.
28
+     *
29
+     * @var array
30
+     */
31
+    protected $meta = array();
32
+
33
+    /**
34
+     * Is this item required?
35
+     *
36
+     * @var int
37
+     */
38
+    protected $is_required = true;
39
+
40
+    /**
41
+     * Are quantities allowed?
42
+     *
43
+     * @var int
44
+     */
45
+    protected $allow_quantities = false;
46
+
47
+    /**
48
+     * Associated invoice.
49
+     *
50
+     * @var int
51
+     */
52
+    public $invoice_id = 0;
53
+
54
+    /**
55
+     * Item discount.
56
+     *
57
+     * @var float
58
+     */
59
+    public $item_discount = 0;
60
+
61
+    /**
62
+     * Item tax.
63
+     *
64
+     * @var float
65
+     */
66
+    public $item_tax = 0;
67 67
 
68 68
     /*
69 69
 	|--------------------------------------------------------------------------
@@ -81,234 +81,234 @@  discard block
 block discarded – undo
81 81
     */
82 82
 
83 83
     /**
84
-	 * Get the item name.
85
-	 *
86
-	 * @since 1.0.19
87
-	 * @param  string $context View or edit context.
88
-	 * @return string
89
-	 */
90
-	public function get_name( $context = 'view' ) {
91
-		$name = parent::get_name( $context );
92
-		return $name . wpinv_get_item_suffix( $this );
93
-	}
94
-
95
-	/**
96
-	 * Get the item name without a suffix.
97
-	 *
98
-	 * @since 1.0.19
99
-	 * @param  string $context View or edit context.
100
-	 * @return string
101
-	 */
102
-	public function get_raw_name( $context = 'view' ) {
103
-		return parent::get_name( $context );
104
-	}
105
-
106
-	/**
107
-	 * Get the item description.
108
-	 *
109
-	 * @since 1.0.19
110
-	 * @param  string $context View or edit context.
111
-	 * @return string
112
-	 */
113
-	public function get_description( $context = 'view' ) {
114
-
115
-		if ( isset( $this->custom_description ) ) {
116
-			return $this->custom_description;
117
-		}
118
-
119
-		return parent::get_description( $context );
120
-	}
121
-
122
-	/**
123
-	 * Returns the sub total.
124
-	 *
125
-	 * @since 1.0.19
126
-	 * @param  string $context View or edit context.
127
-	 * @return float
128
-	 */
129
-	public function get_sub_total( $context = 'view' ) {
130
-		return $this->get_quantity( $context ) * $this->get_initial_price( $context );
131
-	}
132
-
133
-	/**
134
-	 * Returns the recurring sub total.
135
-	 *
136
-	 * @since 1.0.19
137
-	 * @param  string $context View or edit context.
138
-	 * @return float
139
-	 */
140
-	public function get_recurring_sub_total( $context = 'view' ) {
141
-
142
-		if ( $this->is_recurring() ) {
143
-			return $this->get_quantity( $context ) * $this->get_price( $context );
144
-		}
145
-
146
-		return 0;
147
-	}
148
-
149
-	/**
150
-	 * @deprecated
151
-	 */
152
-	public function get_qantity( $context = 'view' ) {
153
-		return $this->get_quantity( $context );
154
-	}
155
-
156
-	/**
157
-	 * Get the item quantity.
158
-	 *
159
-	 * @since 1.0.19
160
-	 * @param  string $context View or edit context.
161
-	 * @return float
162
-	 */
163
-	public function get_quantity( $context = 'view' ) {
164
-		$quantity = (float) $this->quantity;
165
-
166
-		if ( empty( $quantity ) || 1 > $quantity ) {
167
-			$quantity = 1;
168
-		}
169
-
170
-		if ( 'view' == $context ) {
171
-			return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this );
172
-		}
173
-
174
-		return $quantity;
175
-
176
-	}
177
-
178
-	/**
179
-	 * Get the item meta data.
180
-	 *
181
-	 * @since 1.0.19
182
-	 * @param  string $context View or edit context.
183
-	 * @return meta
184
-	 */
185
-	public function get_item_meta( $context = 'view' ) {
186
-		$meta = $this->meta;
187
-
188
-		if ( 'view' == $context ) {
189
-			return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this );
190
-		}
191
-
192
-		return $meta;
193
-
194
-	}
195
-
196
-	/**
197
-	 * Returns whether or not customers can update the item quantity.
198
-	 *
199
-	 * @since 1.0.19
200
-	 * @param  string $context View or edit context.
201
-	 * @return bool
202
-	 */
203
-	public function get_allow_quantities( $context = 'view' ) {
204
-		$allow_quantities = (bool) $this->allow_quantities;
205
-
206
-		if ( 'view' == $context ) {
207
-			return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this );
208
-		}
209
-
210
-		return $allow_quantities;
211
-
212
-	}
213
-
214
-	/**
215
-	 * Returns whether or not the item is required.
216
-	 *
217
-	 * @since 1.0.19
218
-	 * @param  string $context View or edit context.
219
-	 * @return bool
220
-	 */
221
-	public function get_is_required( $context = 'view' ) {
222
-		$is_required = (bool) $this->is_required;
223
-
224
-		if ( 'view' == $context ) {
225
-			return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this );
226
-		}
227
-
228
-		return $is_required;
229
-
230
-	}
231
-
232
-	/**
233
-	 * Prepares form data for use.
234
-	 *
235
-	 * @since 1.0.19
236
-	 * @return array
237
-	 */
238
-	public function prepare_data_for_use( $required = null ) {
239
-
240
-		$required = is_null( $required ) ? $this->is_required() : $required;
241
-		return array(
242
-			'title'            => strip_tags( $this->get_name() ),
243
-			'id'               => $this->get_id(),
244
-			'price'            => $this->get_price(),
245
-			'recurring'        => $this->is_recurring(),
246
-			'description'      => $this->get_description(),
247
-			'allow_quantities' => $this->allows_quantities(),
248
-			'required'         => $required,
249
-		);
250
-
251
-	}
252
-
253
-	/**
254
-	 * Prepares form data for ajax use.
255
-	 *
256
-	 * @since 1.0.19
257
-	 * @return array
258
-	 */
259
-	public function prepare_data_for_invoice_edit_ajax( $currency = '', $is_renewal = false ) {
260
-
261
-		$description = getpaid_item_recurring_price_help_text( $this, $currency );
262
-
263
-		if ( $description ) {
264
-			$description = "<div class='getpaid-subscription-help-text'>$description</div>";
265
-		}
266
-
267
-		$price    = ! $is_renewal ? $this->get_price() : $this->get_recurring_price();
268
-		$subtotal = ! $is_renewal ? $this->get_sub_total() : $this->get_recurring_sub_total();
269
-		return array(
270
-			'id'     => $this->get_id(),
271
-			'texts'  => array(
272
-				'item-name'        => sanitize_text_field( $this->get_name() ),
273
-				'item-description' => wp_kses_post( $this->get_description() ) . $description,
274
-				'item-quantity'    => floatval( $this->get_quantity() ),
275
-				'item-price'       => wpinv_price( $price, $currency ),
276
-				'item-total'       => wpinv_price( $subtotal, $currency ),
277
-			),
278
-			'inputs' => array(
279
-				'item-id'          => $this->get_id(),
280
-				'item-name'        => sanitize_text_field( $this->get_name() ),
281
-				'item-description' => wp_kses_post( $this->get_description() ),
282
-				'item-quantity'    => floatval( $this->get_quantity() ),
283
-				'item-price'       => $price,
284
-			)
285
-		);
286
-
287
-	}
288
-
289
-	/**
290
-	 * Prepares form data for saving (cart_details).
291
-	 *
292
-	 * @since 1.0.19
293
-	 * @return array
294
-	 */
295
-	public function prepare_data_for_saving() {
296
-
297
-		return array(
298
-			'post_id'           => $this->invoice_id,
299
-			'item_id'           => $this->get_id(),
300
-			'item_name'         => sanitize_text_field( $this->get_raw_name() ),
301
-			'item_description'  => $this->get_description(),
302
-			'tax'               => $this->item_tax,
303
-			'item_price'        => $this->get_price(),
304
-			'quantity'          => (float) $this->get_quantity(),
305
-			'discount'          => $this->item_discount,
306
-			'subtotal'          => $this->get_sub_total(),
307
-			'price'             => $this->get_sub_total() + $this->item_tax + $this->item_discount,
308
-			'meta'              => $this->get_item_meta(),
309
-		);
310
-
311
-	}
84
+     * Get the item name.
85
+     *
86
+     * @since 1.0.19
87
+     * @param  string $context View or edit context.
88
+     * @return string
89
+     */
90
+    public function get_name( $context = 'view' ) {
91
+        $name = parent::get_name( $context );
92
+        return $name . wpinv_get_item_suffix( $this );
93
+    }
94
+
95
+    /**
96
+     * Get the item name without a suffix.
97
+     *
98
+     * @since 1.0.19
99
+     * @param  string $context View or edit context.
100
+     * @return string
101
+     */
102
+    public function get_raw_name( $context = 'view' ) {
103
+        return parent::get_name( $context );
104
+    }
105
+
106
+    /**
107
+     * Get the item description.
108
+     *
109
+     * @since 1.0.19
110
+     * @param  string $context View or edit context.
111
+     * @return string
112
+     */
113
+    public function get_description( $context = 'view' ) {
114
+
115
+        if ( isset( $this->custom_description ) ) {
116
+            return $this->custom_description;
117
+        }
118
+
119
+        return parent::get_description( $context );
120
+    }
121
+
122
+    /**
123
+     * Returns the sub total.
124
+     *
125
+     * @since 1.0.19
126
+     * @param  string $context View or edit context.
127
+     * @return float
128
+     */
129
+    public function get_sub_total( $context = 'view' ) {
130
+        return $this->get_quantity( $context ) * $this->get_initial_price( $context );
131
+    }
132
+
133
+    /**
134
+     * Returns the recurring sub total.
135
+     *
136
+     * @since 1.0.19
137
+     * @param  string $context View or edit context.
138
+     * @return float
139
+     */
140
+    public function get_recurring_sub_total( $context = 'view' ) {
141
+
142
+        if ( $this->is_recurring() ) {
143
+            return $this->get_quantity( $context ) * $this->get_price( $context );
144
+        }
145
+
146
+        return 0;
147
+    }
148
+
149
+    /**
150
+     * @deprecated
151
+     */
152
+    public function get_qantity( $context = 'view' ) {
153
+        return $this->get_quantity( $context );
154
+    }
155
+
156
+    /**
157
+     * Get the item quantity.
158
+     *
159
+     * @since 1.0.19
160
+     * @param  string $context View or edit context.
161
+     * @return float
162
+     */
163
+    public function get_quantity( $context = 'view' ) {
164
+        $quantity = (float) $this->quantity;
165
+
166
+        if ( empty( $quantity ) || 1 > $quantity ) {
167
+            $quantity = 1;
168
+        }
169
+
170
+        if ( 'view' == $context ) {
171
+            return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this );
172
+        }
173
+
174
+        return $quantity;
175
+
176
+    }
177
+
178
+    /**
179
+     * Get the item meta data.
180
+     *
181
+     * @since 1.0.19
182
+     * @param  string $context View or edit context.
183
+     * @return meta
184
+     */
185
+    public function get_item_meta( $context = 'view' ) {
186
+        $meta = $this->meta;
187
+
188
+        if ( 'view' == $context ) {
189
+            return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this );
190
+        }
191
+
192
+        return $meta;
193
+
194
+    }
195
+
196
+    /**
197
+     * Returns whether or not customers can update the item quantity.
198
+     *
199
+     * @since 1.0.19
200
+     * @param  string $context View or edit context.
201
+     * @return bool
202
+     */
203
+    public function get_allow_quantities( $context = 'view' ) {
204
+        $allow_quantities = (bool) $this->allow_quantities;
205
+
206
+        if ( 'view' == $context ) {
207
+            return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this );
208
+        }
209
+
210
+        return $allow_quantities;
211
+
212
+    }
213
+
214
+    /**
215
+     * Returns whether or not the item is required.
216
+     *
217
+     * @since 1.0.19
218
+     * @param  string $context View or edit context.
219
+     * @return bool
220
+     */
221
+    public function get_is_required( $context = 'view' ) {
222
+        $is_required = (bool) $this->is_required;
223
+
224
+        if ( 'view' == $context ) {
225
+            return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this );
226
+        }
227
+
228
+        return $is_required;
229
+
230
+    }
231
+
232
+    /**
233
+     * Prepares form data for use.
234
+     *
235
+     * @since 1.0.19
236
+     * @return array
237
+     */
238
+    public function prepare_data_for_use( $required = null ) {
239
+
240
+        $required = is_null( $required ) ? $this->is_required() : $required;
241
+        return array(
242
+            'title'            => strip_tags( $this->get_name() ),
243
+            'id'               => $this->get_id(),
244
+            'price'            => $this->get_price(),
245
+            'recurring'        => $this->is_recurring(),
246
+            'description'      => $this->get_description(),
247
+            'allow_quantities' => $this->allows_quantities(),
248
+            'required'         => $required,
249
+        );
250
+
251
+    }
252
+
253
+    /**
254
+     * Prepares form data for ajax use.
255
+     *
256
+     * @since 1.0.19
257
+     * @return array
258
+     */
259
+    public function prepare_data_for_invoice_edit_ajax( $currency = '', $is_renewal = false ) {
260
+
261
+        $description = getpaid_item_recurring_price_help_text( $this, $currency );
262
+
263
+        if ( $description ) {
264
+            $description = "<div class='getpaid-subscription-help-text'>$description</div>";
265
+        }
266
+
267
+        $price    = ! $is_renewal ? $this->get_price() : $this->get_recurring_price();
268
+        $subtotal = ! $is_renewal ? $this->get_sub_total() : $this->get_recurring_sub_total();
269
+        return array(
270
+            'id'     => $this->get_id(),
271
+            'texts'  => array(
272
+                'item-name'        => sanitize_text_field( $this->get_name() ),
273
+                'item-description' => wp_kses_post( $this->get_description() ) . $description,
274
+                'item-quantity'    => floatval( $this->get_quantity() ),
275
+                'item-price'       => wpinv_price( $price, $currency ),
276
+                'item-total'       => wpinv_price( $subtotal, $currency ),
277
+            ),
278
+            'inputs' => array(
279
+                'item-id'          => $this->get_id(),
280
+                'item-name'        => sanitize_text_field( $this->get_name() ),
281
+                'item-description' => wp_kses_post( $this->get_description() ),
282
+                'item-quantity'    => floatval( $this->get_quantity() ),
283
+                'item-price'       => $price,
284
+            )
285
+        );
286
+
287
+    }
288
+
289
+    /**
290
+     * Prepares form data for saving (cart_details).
291
+     *
292
+     * @since 1.0.19
293
+     * @return array
294
+     */
295
+    public function prepare_data_for_saving() {
296
+
297
+        return array(
298
+            'post_id'           => $this->invoice_id,
299
+            'item_id'           => $this->get_id(),
300
+            'item_name'         => sanitize_text_field( $this->get_raw_name() ),
301
+            'item_description'  => $this->get_description(),
302
+            'tax'               => $this->item_tax,
303
+            'item_price'        => $this->get_price(),
304
+            'quantity'          => (float) $this->get_quantity(),
305
+            'discount'          => $this->item_discount,
306
+            'subtotal'          => $this->get_sub_total(),
307
+            'price'             => $this->get_sub_total() + $this->item_tax + $this->item_discount,
308
+            'meta'              => $this->get_item_meta(),
309
+        );
310
+
311
+    }
312 312
 
313 313
     /*
314 314
 	|--------------------------------------------------------------------------
@@ -320,70 +320,70 @@  discard block
 block discarded – undo
320 320
 	| object.
321 321
     */
322 322
 
323
-	/**
324
-	 * Set the item qantity.
325
-	 *
326
-	 * @since 1.0.19
327
-	 * @param  float $quantity The item quantity.
328
-	 */
329
-	public function set_quantity( $quantity ) {
330
-
331
-		if ( empty( $quantity ) || ! is_numeric( $quantity ) ) {
332
-			$quantity = 1;
333
-		}
334
-
335
-		$this->quantity = (float) $quantity;
336
-
337
-	}
338
-
339
-	/**
340
-	 * Set the item meta data.
341
-	 *
342
-	 * @since 1.0.19
343
-	 * @param  array $meta The item meta data.
344
-	 */
345
-	public function set_item_meta( $meta ) {
346
-		$this->meta = maybe_unserialize( $meta );
347
-	}
348
-
349
-	/**
350
-	 * Set whether or not the quantities are allowed.
351
-	 *
352
-	 * @since 1.0.19
353
-	 * @param  bool $allow_quantities
354
-	 */
355
-	public function set_allow_quantities( $allow_quantities ) {
356
-		$this->allow_quantities = (bool) $allow_quantities;
357
-	}
358
-
359
-	/**
360
-	 * Set whether or not the item is required.
361
-	 *
362
-	 * @since 1.0.19
363
-	 * @param  bool $is_required
364
-	 */
365
-	public function set_is_required( $is_required ) {
366
-		$this->is_required = (bool) $is_required;
367
-	}
368
-
369
-	/**
370
-	 * Sets the custom item description.
371
-	 *
372
-	 * @since 1.0.19
373
-	 * @param  string $description
374
-	 */
375
-	public function set_custom_description( $description ) {
376
-		$this->custom_description = $description;
377
-	}
323
+    /**
324
+     * Set the item qantity.
325
+     *
326
+     * @since 1.0.19
327
+     * @param  float $quantity The item quantity.
328
+     */
329
+    public function set_quantity( $quantity ) {
330
+
331
+        if ( empty( $quantity ) || ! is_numeric( $quantity ) ) {
332
+            $quantity = 1;
333
+        }
334
+
335
+        $this->quantity = (float) $quantity;
336
+
337
+    }
338
+
339
+    /**
340
+     * Set the item meta data.
341
+     *
342
+     * @since 1.0.19
343
+     * @param  array $meta The item meta data.
344
+     */
345
+    public function set_item_meta( $meta ) {
346
+        $this->meta = maybe_unserialize( $meta );
347
+    }
348
+
349
+    /**
350
+     * Set whether or not the quantities are allowed.
351
+     *
352
+     * @since 1.0.19
353
+     * @param  bool $allow_quantities
354
+     */
355
+    public function set_allow_quantities( $allow_quantities ) {
356
+        $this->allow_quantities = (bool) $allow_quantities;
357
+    }
358
+
359
+    /**
360
+     * Set whether or not the item is required.
361
+     *
362
+     * @since 1.0.19
363
+     * @param  bool $is_required
364
+     */
365
+    public function set_is_required( $is_required ) {
366
+        $this->is_required = (bool) $is_required;
367
+    }
368
+
369
+    /**
370
+     * Sets the custom item description.
371
+     *
372
+     * @since 1.0.19
373
+     * @param  string $description
374
+     */
375
+    public function set_custom_description( $description ) {
376
+        $this->custom_description = $description;
377
+    }
378 378
 
379 379
     /**
380 380
      * We do not want to save items to the database.
381 381
      * 
382
-	 * @return int item id
382
+     * @return int item id
383 383
      */
384 384
     public function save( $data = array() ) {
385 385
         return $this->get_id();
386
-	}
386
+    }
387 387
 
388 388
     /*
389 389
 	|--------------------------------------------------------------------------
@@ -395,23 +395,23 @@  discard block
 block discarded – undo
395 395
 	*/
396 396
 
397 397
     /**
398
-	 * Checks whether the item has enabled dynamic pricing.
399
-	 *
400
-	 * @since 1.0.19
401
-	 * @return bool
402
-	 */
403
-	public function is_required() {
398
+     * Checks whether the item has enabled dynamic pricing.
399
+     *
400
+     * @since 1.0.19
401
+     * @return bool
402
+     */
403
+    public function is_required() {
404 404
         return (bool) $this->get_is_required();
405
-	}
406
-
407
-	/**
408
-	 * Checks whether users can edit the quantities.
409
-	 *
410
-	 * @since 1.0.19
411
-	 * @return bool
412
-	 */
413
-	public function allows_quantities() {
405
+    }
406
+
407
+    /**
408
+     * Checks whether users can edit the quantities.
409
+     *
410
+     * @since 1.0.19
411
+     * @return bool
412
+     */
413
+    public function allows_quantities() {
414 414
         return (bool) $this->get_allow_quantities();
415
-	}
415
+    }
416 416
 
417 417
 }
Please login to merge, or discard this patch.