Completed
Pull Request — master (#517)
by Chris
15:12
created
includes/class-give-donate-form.php 1 patch
Spacing   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -73,37 +73,37 @@  discard block
 block discarded – undo
73 73
 	 * @param bool  $_id
74 74
 	 * @param array $_args
75 75
 	 */
76
-	public function __construct( $_id = false, $_args = array() ) {
76
+	public function __construct($_id = false, $_args = array()) {
77 77
 
78
-		if ( false === $_id ) {
78
+		if (false === $_id) {
79 79
 
80 80
 			$defaults = array(
81 81
 				'post_type'   => 'give_forms',
82 82
 				'post_status' => 'draft',
83
-				'post_title'  => __( 'New Give Form', 'give' )
83
+				'post_title'  => __('New Give Form', 'give')
84 84
 			);
85 85
 
86
-			$args = wp_parse_args( $_args, $defaults );
86
+			$args = wp_parse_args($_args, $defaults);
87 87
 
88
-			$_id = wp_insert_post( $args, true );
88
+			$_id = wp_insert_post($args, true);
89 89
 
90 90
 		}
91 91
 
92
-		$donate_form = WP_Post::get_instance( $_id );
92
+		$donate_form = WP_Post::get_instance($_id);
93 93
 
94
-		if ( ! is_object( $donate_form ) ) {
94
+		if ( ! is_object($donate_form)) {
95 95
 			return false;
96 96
 		}
97 97
 
98
-		if ( ! is_a( $donate_form, 'WP_Post' ) ) {
98
+		if ( ! is_a($donate_form, 'WP_Post')) {
99 99
 			return false;
100 100
 		}
101 101
 
102
-		if ( 'give_forms' !== $donate_form->post_type ) {
102
+		if ('give_forms' !== $donate_form->post_type) {
103 103
 			return false;
104 104
 		}
105 105
 
106
-		foreach ( $donate_form as $key => $value ) {
106
+		foreach ($donate_form as $key => $value) {
107 107
 
108 108
 			$this->$key = $value;
109 109
 
@@ -121,15 +121,15 @@  discard block
 block discarded – undo
121 121
 	 * @return mixed
122 122
 	 * @throws Exception
123 123
 	 */
124
-	public function __get( $key ) {
124
+	public function __get($key) {
125 125
 
126
-		if ( method_exists( $this, 'get_' . $key ) ) {
126
+		if (method_exists($this, 'get_'.$key)) {
127 127
 
128
-			return call_user_func( array( $this, 'get_' . $key ) );
128
+			return call_user_func(array($this, 'get_'.$key));
129 129
 
130 130
 		} else {
131 131
 
132
-			throw new Exception( 'Can\'t get property ' . $key );
132
+			throw new Exception('Can\'t get property '.$key);
133 133
 
134 134
 		}
135 135
 
@@ -155,13 +155,13 @@  discard block
 block discarded – undo
155 155
 	 */
156 156
 	public function get_price() {
157 157
 
158
-		if ( ! isset( $this->price ) ) {
158
+		if ( ! isset($this->price)) {
159 159
 
160
-			$this->price = get_post_meta( $this->ID, '_give_set_price', true );
160
+			$this->price = get_post_meta($this->ID, '_give_set_price', true);
161 161
 
162
-			if ( $this->price ) {
162
+			if ($this->price) {
163 163
 
164
-				$this->price = give_sanitize_amount( $this->price );
164
+				$this->price = give_sanitize_amount($this->price);
165 165
 
166 166
 			} else {
167 167
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 
172 172
 		}
173 173
 
174
-		return apply_filters( 'give_get_set_price', $this->price, $this->ID );
174
+		return apply_filters('give_get_set_price', $this->price, $this->ID);
175 175
 	}
176 176
 
177 177
 	/**
@@ -182,14 +182,14 @@  discard block
 block discarded – undo
182 182
 	 */
183 183
 	public function get_minimum_price() {
184 184
 
185
-		if ( ! isset( $this->minimum_price ) ) {
185
+		if ( ! isset($this->minimum_price)) {
186 186
 
187
-			$allow_custom_amount = get_post_meta( $this->ID, '_give_custom_amount', true );
188
-			$this->minimum_price = get_post_meta( $this->ID, '_give_custom_amount_minimum', true );
187
+			$allow_custom_amount = get_post_meta($this->ID, '_give_custom_amount', true);
188
+			$this->minimum_price = get_post_meta($this->ID, '_give_custom_amount_minimum', true);
189 189
 
190
-			if ( $allow_custom_amount != 'no' && $this->minimum_price ) {
190
+			if ($allow_custom_amount != 'no' && $this->minimum_price) {
191 191
 
192
-				$this->minimum_price = give_sanitize_amount( $this->minimum_price );
192
+				$this->minimum_price = give_sanitize_amount($this->minimum_price);
193 193
 
194 194
 			} else {
195 195
 
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
 
200 200
 		}
201 201
 
202
-		return apply_filters( 'give_get_set_minimum_price', $this->minimum_price, $this->ID );
202
+		return apply_filters('give_get_set_minimum_price', $this->minimum_price, $this->ID);
203 203
 	}
204 204
 
205 205
 	/**
@@ -210,13 +210,13 @@  discard block
 block discarded – undo
210 210
 	 */
211 211
 	public function get_prices() {
212 212
 
213
-		if ( ! isset( $this->prices ) ) {
213
+		if ( ! isset($this->prices)) {
214 214
 
215
-			$this->prices = get_post_meta( $this->ID, '_give_donation_levels', true );
215
+			$this->prices = get_post_meta($this->ID, '_give_donation_levels', true);
216 216
 
217 217
 		}
218 218
 
219
-		return apply_filters( 'give_get_donation_levels', $this->prices, $this->ID );
219
+		return apply_filters('give_get_donation_levels', $this->prices, $this->ID);
220 220
 
221 221
 	}
222 222
 
@@ -228,13 +228,13 @@  discard block
 block discarded – undo
228 228
 	 */
229 229
 	public function get_goal() {
230 230
 
231
-		if ( ! isset( $this->goal ) ) {
231
+		if ( ! isset($this->goal)) {
232 232
 
233
-			$this->goal = get_post_meta( $this->ID, '_give_set_goal', true );
233
+			$this->goal = get_post_meta($this->ID, '_give_set_goal', true);
234 234
 
235
-			if ( $this->goal ) {
235
+			if ($this->goal) {
236 236
 
237
-				$this->goal = give_sanitize_amount( $this->goal );
237
+				$this->goal = give_sanitize_amount($this->goal);
238 238
 
239 239
 			} else {
240 240
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 
245 245
 		}
246 246
 
247
-		return apply_filters( 'give_get_set_goal', $this->goal, $this->ID );
247
+		return apply_filters('give_get_set_goal', $this->goal, $this->ID);
248 248
 
249 249
 	}
250 250
 
@@ -256,14 +256,14 @@  discard block
 block discarded – undo
256 256
 	 */
257 257
 	public function is_single_price_mode() {
258 258
 
259
-		$option = get_post_meta( $this->ID, '_give_price_options_mode', true );
259
+		$option = get_post_meta($this->ID, '_give_price_options_mode', true);
260 260
 		$ret    = 0;
261 261
 
262
-		if ( empty( $option ) || $option === 'set' ) {
262
+		if (empty($option) || $option === 'set') {
263 263
 			$ret = 1;
264 264
 		}
265 265
 
266
-		return (bool) apply_filters( 'give_single_price_option_mode', $ret, $this->ID );
266
+		return (bool) apply_filters('give_single_price_option_mode', $ret, $this->ID);
267 267
 
268 268
 	}
269 269
 
@@ -277,14 +277,14 @@  discard block
 block discarded – undo
277 277
 	 */
278 278
 	public function has_variable_prices() {
279 279
 
280
-		$option = get_post_meta( $this->ID, '_give_price_option', true );
280
+		$option = get_post_meta($this->ID, '_give_price_option', true);
281 281
 		$ret    = 0;
282 282
 
283
-		if ( $option === 'multi' ) {
283
+		if ($option === 'multi') {
284 284
 			$ret = 1;
285 285
 		}
286 286
 
287
-		return (bool) apply_filters( 'give_has_variable_prices', $ret, $this->ID );
287
+		return (bool) apply_filters('give_has_variable_prices', $ret, $this->ID);
288 288
 
289 289
 	}
290 290
 
@@ -297,15 +297,15 @@  discard block
 block discarded – undo
297 297
 	 */
298 298
 	public function get_sales() {
299 299
 
300
-		if ( ! isset( $this->sales ) ) {
300
+		if ( ! isset($this->sales)) {
301 301
 
302
-			if ( '' == get_post_meta( $this->ID, '_give_form_sales', true ) ) {
303
-				add_post_meta( $this->ID, '_give_form_sales', 0 );
302
+			if ('' == get_post_meta($this->ID, '_give_form_sales', true)) {
303
+				add_post_meta($this->ID, '_give_form_sales', 0);
304 304
 			} // End if
305 305
 
306
-			$this->sales = get_post_meta( $this->ID, '_give_form_sales', true );
306
+			$this->sales = get_post_meta($this->ID, '_give_form_sales', true);
307 307
 
308
-			if ( $this->sales < 0 ) {
308
+			if ($this->sales < 0) {
309 309
 				// Never let sales be less than zero
310 310
 				$this->sales = 0;
311 311
 			}
@@ -324,10 +324,10 @@  discard block
 block discarded – undo
324 324
 	 */
325 325
 	public function increase_sales() {
326 326
 
327
-		$sales = give_get_form_sales_stats( $this->ID );
327
+		$sales = give_get_form_sales_stats($this->ID);
328 328
 		$sales = $sales + 1;
329 329
 
330
-		if ( update_post_meta( $this->ID, '_give_form_sales', $sales ) ) {
330
+		if (update_post_meta($this->ID, '_give_form_sales', $sales)) {
331 331
 			$this->sales = $sales;
332 332
 
333 333
 			return $sales;
@@ -344,13 +344,13 @@  discard block
 block discarded – undo
344 344
 	 */
345 345
 	public function decrease_sales() {
346 346
 
347
-		$sales = give_get_form_sales_stats( $this->ID );
348
-		if ( $sales > 0 ) // Only decrease if not already zero
347
+		$sales = give_get_form_sales_stats($this->ID);
348
+		if ($sales > 0) // Only decrease if not already zero
349 349
 		{
350 350
 			$sales = $sales - 1;
351 351
 		}
352 352
 
353
-		if ( update_post_meta( $this->ID, '_give_form_sales', $sales ) ) {
353
+		if (update_post_meta($this->ID, '_give_form_sales', $sales)) {
354 354
 			$this->sales = $sales;
355 355
 
356 356
 			return $sales;
@@ -368,15 +368,15 @@  discard block
 block discarded – undo
368 368
 	 */
369 369
 	public function get_earnings() {
370 370
 
371
-		if ( ! isset( $this->earnings ) ) {
371
+		if ( ! isset($this->earnings)) {
372 372
 
373
-			if ( '' == get_post_meta( $this->ID, '_give_form_earnings', true ) ) {
374
-				add_post_meta( $this->ID, '_give_form_earnings', 0 );
373
+			if ('' == get_post_meta($this->ID, '_give_form_earnings', true)) {
374
+				add_post_meta($this->ID, '_give_form_earnings', 0);
375 375
 			}
376 376
 
377
-			$this->earnings = get_post_meta( $this->ID, '_give_form_earnings', true );
377
+			$this->earnings = get_post_meta($this->ID, '_give_form_earnings', true);
378 378
 
379
-			if ( $this->earnings < 0 ) {
379
+			if ($this->earnings < 0) {
380 380
 				// Never let earnings be less than zero
381 381
 				$this->earnings = 0;
382 382
 			}
@@ -393,12 +393,12 @@  discard block
 block discarded – undo
393 393
 	 * @since 1.0
394 394
 	 * @return float|false
395 395
 	 */
396
-	public function increase_earnings( $amount = 0 ) {
396
+	public function increase_earnings($amount = 0) {
397 397
 
398
-		$earnings = give_get_form_earnings_stats( $this->ID );
398
+		$earnings = give_get_form_earnings_stats($this->ID);
399 399
 		$earnings = $earnings + (float) $amount;
400 400
 
401
-		if ( update_post_meta( $this->ID, '_give_form_earnings', $earnings ) ) {
401
+		if (update_post_meta($this->ID, '_give_form_earnings', $earnings)) {
402 402
 			$this->earnings = $earnings;
403 403
 
404 404
 			return $earnings;
@@ -414,16 +414,16 @@  discard block
 block discarded – undo
414 414
 	 * @since 1.0
415 415
 	 * @return float|false
416 416
 	 */
417
-	public function decrease_earnings( $amount ) {
417
+	public function decrease_earnings($amount) {
418 418
 
419
-		$earnings = give_get_form_earnings_stats( $this->ID );
419
+		$earnings = give_get_form_earnings_stats($this->ID);
420 420
 
421
-		if ( $earnings > 0 ) // Only decrease if greater than zero
421
+		if ($earnings > 0) // Only decrease if greater than zero
422 422
 		{
423 423
 			$earnings = $earnings - (float) $amount;
424 424
 		}
425 425
 
426
-		if ( update_post_meta( $this->ID, '_give_form_earnings', $earnings ) ) {
426
+		if (update_post_meta($this->ID, '_give_form_earnings', $earnings)) {
427 427
 			$this->earnings = $earnings;
428 428
 
429 429
 			return $earnings;
@@ -439,22 +439,22 @@  discard block
 block discarded – undo
439 439
 	 * @since 1.0
440 440
 	 * @return bool
441 441
 	 */
442
-	public function is_free( $price_id = false ) {
442
+	public function is_free($price_id = false) {
443 443
 
444 444
 		$is_free          = false;
445
-		$variable_pricing = give_has_variable_prices( $this->ID );
445
+		$variable_pricing = give_has_variable_prices($this->ID);
446 446
 
447
-		if ( $variable_pricing && ! is_null( $price_id ) && $price_id !== false ) {
448
-			$price = give_get_price_option_amount( $this->ID, $price_id );
449
-		} elseif ( ! $variable_pricing ) {
450
-			$price = get_post_meta( $this->ID, '_give_set_price', true );
447
+		if ($variable_pricing && ! is_null($price_id) && $price_id !== false) {
448
+			$price = give_get_price_option_amount($this->ID, $price_id);
449
+		} elseif ( ! $variable_pricing) {
450
+			$price = get_post_meta($this->ID, '_give_set_price', true);
451 451
 		}
452 452
 
453
-		if ( isset( $price ) && (float) $price == 0 ) {
453
+		if (isset($price) && (float) $price == 0) {
454 454
 			$is_free = true;
455 455
 		}
456 456
 
457
-		return (bool) apply_filters( 'give_is_free_donation', $is_free, $this->ID, $price_id );
457
+		return (bool) apply_filters('give_is_free_donation', $is_free, $this->ID, $price_id);
458 458
 
459 459
 	}
460 460
 
Please login to merge, or discard this patch.