Test Failed
Push — issues/2042 ( e8b6b5 )
by Ravinder
05:59
created

deprecated-functions.php ➔ give_increase_purchase_count()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Deprecated Functions
4
 *
5
 * All functions that have been deprecated.
6
 *
7
 * @package     Give
8
 * @subpackage  Deprecated
9
 * @copyright   Copyright (c) 2016, WordImpress
10
 * @license     https://opensource.org/licenses/gpl-license GNU Public License
11
 * @since       1.4.1
12
 */
13
14
// Exit if accessed directly.
15
if ( ! defined( 'ABSPATH' ) ) {
16
	exit;
17
}
18
19
/**
20
 * Deprecated global variables.
21
 *
22
 * @since 2.0
23
 *
24
 * @param Give $give_object
25
 */
26
function _give_load_deprecated_global_params( $give_object ) {
27
	$GLOBALS['give_cron'] = Give_Cron::get_instance();
28
}
29
30
add_action( 'give_init', '_give_load_deprecated_global_params' );
31
32
33
34
/**
35
 * Checks if Guest checkout is enabled for a particular donation form
36
 *
37
 * @since      1.0
38
 * @deprecated 1.4.1
39
 *
40
 * @param int $form_id
41
 *
42
 * @return bool $ret True if guest checkout is enabled, false otherwise
43
 */
44
function give_no_guest_checkout( $form_id ) {
45
46
	$backtrace = debug_backtrace();
47
48
	_give_deprecated_function( __FUNCTION__, '1.4.1', null, $backtrace );
49
50
	$ret = give_get_meta( $form_id, '_give_logged_in_only', true );
51
52
	return (bool) apply_filters( 'give_no_guest_checkout', give_is_setting_enabled( $ret ) );
53
}
54
55
56
/**
57
 * Default Log Views
58
 *
59
 * @since      1.0
60
 * @deprecated 1.8
61
 * @return array $views Log Views
62
 */
63
function give_log_default_views() {
64
65
	$backtrace = debug_backtrace();
66
67
	_give_deprecated_function( __FUNCTION__, '1.8', null, $backtrace );
68
69
	$views = array(
70
		'sales'          => __( 'Donations', 'give' ),
71
		'gateway_errors' => __( 'Payment Errors', 'give' ),
72
		'api_requests'   => __( 'API Requests', 'give' ),
73
	);
74
75
	$views = apply_filters( 'give_log_views', $views );
76
77
	return $views;
78
}
79
80
/**
81
 * Donation form validate agree to "Terms and Conditions".
82
 *
83
 * @since      1.0
84
 * @deprecated 1.8.8
85
 */
86
function give_purchase_form_validate_agree_to_terms() {
87
88
	$backtrace = debug_backtrace();
89
90
	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_agree_to_terms', $backtrace );
91
92
	// Call new renamed function.
93
	give_donation_form_validate_agree_to_terms();
94
95
}
96
97
/**
98
 * Donation Form Validate Logged In User.
99
 *
100
 * @since      1.0
101
 * @deprecated 1.8.8
102
 */
103
function give_purchase_form_validate_logged_in_user() {
104
105
	$backtrace = debug_backtrace();
106
107
	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_logged_in_user', $backtrace );
108
109
	// Call new renamed function.
110
	give_donation_form_validate_logged_in_user();
111
112
}
113
114
/**
115
 * Donation Form Validate Logged In User.
116
 *
117
 * @since      1.0
118
 * @deprecated 1.8.8
119
 */
120
function give_purchase_form_validate_gateway() {
121
122
	$backtrace = debug_backtrace();
123
124
	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_gateway', $backtrace );
125
126
	// Call new renamed function.
127
	give_donation_form_validate_gateway();
128
129
}
130
131
/**
132
 * Donation Form Validate Fields.
133
 *
134
 * @since      1.0
135
 * @deprecated 1.8.8
136
 */
137
function give_purchase_form_validate_fields() {
138
139
	$backtrace = debug_backtrace();
140
141
	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_fields', $backtrace );
142
143
	// Call new renamed function.
144
	give_donation_form_validate_fields();
145
146
}
147
148
/**
149
 * Validates the credit card info.
150
 *
151
 * @since      1.0
152
 * @deprecated 1.8.8
153
 */
154
function give_purchase_form_validate_cc() {
155
156
	$backtrace = debug_backtrace();
157
158
	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_cc', $backtrace );
159
160
	// Call new renamed function.
161
	give_donation_form_validate_cc();
162
163
}
164
165
/**
166
 * Validates the credit card info.
167
 *
168
 * @since      1.0
169
 * @deprecated 1.8.8
170
 */
171
function give_get_purchase_cc_info() {
172
173
	$backtrace = debug_backtrace();
174
175
	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_get_donation_cc_info', $backtrace );
176
177
	// Call new renamed function.
178
	give_get_donation_cc_info();
179
180
}
181
182
183
/**
184
 * Validates the credit card info.
185
 *
186
 * @since      1.0
187
 * @deprecated 1.8.8
188
 *
189
 * @param int    $zip
190
 * @param string $country_code
191
 */
192
function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) {
193
194
	$backtrace = debug_backtrace();
195
196
	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_cc_zip', $backtrace );
197
198
	// Call new renamed function.
199
	give_donation_form_validate_cc_zip( $zip, $country_code );
200
201
}
202
203
/**
204
 * Donation form validate user login.
205
 *
206
 * @since      1.0
207
 * @deprecated 1.8.8
208
 */
209
function give_purchase_form_validate_user_login() {
210
211
	$backtrace = debug_backtrace();
212
213
	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_user_login', $backtrace );
214
215
	// Call new renamed function.
216
	give_donation_form_validate_user_login();
217
218
}
219
220
/**
221
 * Donation Form Validate Guest User
222
 *
223
 * @since      1.0
224
 * @deprecated 1.8.8
225
 */
226
function give_purchase_form_validate_guest_user() {
227
228
	$backtrace = debug_backtrace();
229
230
	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_guest_user', $backtrace );
231
232
	// Call new renamed function.
233
	give_donation_form_validate_guest_user();
234
235
}
236
237
/**
238
 * Donate Form Validate New User
239
 *
240
 * @since      1.0
241
 * @deprecated 1.8.8
242
 */
243
function give_purchase_form_validate_new_user() {
244
245
	$backtrace = debug_backtrace();
246
247
	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_new_user', $backtrace );
248
249
	// Call new renamed function.
250
	give_donation_form_validate_new_user();
251
252
}
253
254
255
/**
256
 * Get Donation Form User
257
 *
258
 * @since      1.0
259
 * @deprecated 1.8.8
260
 *
261
 * @param array $valid_data
262
 */
263
function give_get_purchase_form_user( $valid_data = array() ) {
264
265
	$backtrace = debug_backtrace();
266
267
	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_get_donation_form_user', $backtrace );
268
269
	// Call new renamed function.
270
	give_get_donation_form_user( $valid_data );
271
272
}
273
274
/**
275
 * Give Checkout Button.
276
 *
277
 * Renders the button on the Checkout.
278
 *
279
 * @since      1.0
280
 * @deprecated 1.8.8
281
 *
282
 * @param  int $form_id The form ID.
283
 *
284
 * @return string
285
 */
286
function give_checkout_button_purchase( $form_id ) {
287
	$backtrace = debug_backtrace();
288
289
	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_get_donation_form_submit_button', $backtrace );
290
291
	return give_get_donation_form_submit_button( $form_id );
292
293
}
294
295
/**
296
 * Get the donor ID associated with a payment.
297
 *
298
 * @since 1.0
299
 *
300
 * @param int $payment_id Payment ID.
301
 *
302
 * @return int $customer_id Customer ID.
303
 */
304
function give_get_payment_customer_id( $payment_id ) {
305
306
	$backtrace = debug_backtrace();
307
308
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'give_get_payment_donor_id', $backtrace );
309
310
	return give_get_payment_donor_id( $payment_id );
311
}
312
313
314
/**
315
 * Get Total Donations.
316
 *
317
 * @since  1.0
318
 *
319
 * @return int $count Total sales.
320
 */
321
function give_get_total_sales() {
322
323
	$backtrace = debug_backtrace();
324
325
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'give_get_total_donations', $backtrace );
326
327
	return give_get_total_donations();
328
}
329
330
331
/**
332
 * Count number of donations of a donor.
333
 *
334
 * Returns total number of donations a donor has made.
335
 *
336
 * @access      public
337
 * @since       1.0
338
 *
339
 * @param       int|string $user The ID or email of the donor.
340
 *
341
 * @return      int The total number of donations
342
 */
343
function give_count_purchases_of_customer( $user = null ) {
344
345
	$backtrace = debug_backtrace();
346
347
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'give_count_donations_of_donor', $backtrace );
348
349
	return give_count_donations_of_donor( $user );
350
}
351
352
353
/**
354
 * Get Donation Status for User.
355
 *
356
 * Retrieves the donation count and the total amount spent for a specific user.
357
 *
358
 * @access      public
359
 * @since       1.0
360
 *
361
 * @param       int|string $user The ID or email of the donor to retrieve stats for.
362
 *
363
 * @return      array
364
 */
365
function give_get_purchase_stats_by_user( $user = '' ) {
366
367
	$backtrace = debug_backtrace();
368
369
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'give_get_donation_stats_by_user', $backtrace );
370
371
	return give_get_donation_stats_by_user( $user );
372
373
}
374
375
/**
376
 * Get Users Donations
377
 *
378
 * Retrieves a list of all donations by a specific user.
379
 *
380
 * @since  1.0
381
 *
382
 * @param int    $user   User ID or email address
383
 * @param int    $number Number of donations to retrieve
384
 * @param bool   $pagination
385
 * @param string $status
386
 *
387
 * @return bool|object List of all user donations
388
 */
389
function give_get_users_purchases( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) {
390
391
	$backtrace = debug_backtrace();
392
393
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'give_get_users_donations', $backtrace );
394
395
	return give_get_users_donations( $user, $number, $pagination, $status );
396
397
}
398
399
400
/**
401
 * Has donations
402
 *
403
 * Checks to see if a user has donated to at least one form.
404
 *
405
 * @access      public
406
 * @since       1.0
407
 *
408
 * @param       int $user_id The ID of the user to check.
409
 *
410
 * @return      bool True if has donated, false other wise.
411
 */
412
function give_has_purchases( $user_id = null ) {
413
414
	$backtrace = debug_backtrace();
415
416
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'give_has_donations', $backtrace );
417
418
	return give_has_donations( $user_id );
419
}
420
421
/**
422
 * Counts the total number of donors.
423
 *
424
 * @access        public
425
 * @since         1.0
426
 *
427
 * @return        int The total number of donors.
428
 */
429
function give_count_total_customers() {
430
	$backtrace = debug_backtrace();
431
432
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'give_count_total_donors', $backtrace );
433
434
	return give_count_total_donors();
435
}
436
437
/**
438
 * Calculates the total amount spent by a user.
439
 *
440
 * @access      public
441
 * @since       1.0
442
 *
443
 * @param       int|string $user The ID or email of the donor.
444
 *
445
 * @return      float The total amount the user has spent
446
 */
447
function give_purchase_total_of_user( $user = null ) {
448
449
	$backtrace = debug_backtrace();
450
451
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'give_donation_total_of_user', $backtrace );
452
453
	return give_donation_total_of_user( $user );
454
}
455
456
/**
457
 * Deletes a Donation
458
 *
459
 * @since  1.0
460
 * @global      $give_logs
461
 *
462
 * @param  int  $payment_id      Payment ID (default: 0).
463
 * @param  bool $update_customer If we should update the customer stats (default:true).
464
 *
465
 * @return void
466
 */
467
function give_delete_purchase( $payment_id = 0, $update_customer = true ) {
468
469
	$backtrace = debug_backtrace();
470
471
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'give_delete_donation', $backtrace );
472
473
	give_delete_donation( $payment_id, $update_customer );
474
475
}
476
477
478
/**
479
 * Undo Donation
480
 *
481
 * Undoes a donation, including the decrease of donations and earning stats.
482
 * Used for when refunding or deleting a donation.
483
 *
484
 * @since  1.0
485
 *
486
 * @param  int|bool $form_id    Form ID (default: false).
487
 * @param  int      $payment_id Payment ID.
488
 *
489
 * @return void
490
 */
491
function give_undo_purchase( $form_id = false, $payment_id ) {
492
493
	$backtrace = debug_backtrace();
494
495
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'give_undo_donation', $backtrace );
496
497
	give_undo_donation( $payment_id );
498
}
499
500
501
/**
502
 * Trigger a Donation Deletion.
503
 *
504
 * @since 1.0
505
 *
506
 * @param array $data Arguments passed.
507
 *
508
 * @return void
509
 */
510
function give_trigger_purchase_delete( $data ) {
511
	$backtrace = debug_backtrace();
512
513
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'give_trigger_donation_delete', $backtrace );
514
515
	give_trigger_donation_delete( $data );
516
}
517
518
519
/**
520
 * Increases the donation total count of a donation form.
521
 *
522
 * @since 1.0
523
 *
524
 * @param int $form_id  Give Form ID
525
 * @param int $quantity Quantity to increase donation count by
526
 *
527
 * @return bool|int
528
 */
529
function give_increase_purchase_count( $form_id = 0, $quantity = 1 ) {
530
	$backtrace = debug_backtrace();
531
532
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'give_increase_donation_count', $backtrace );
533
534
	give_increase_donation_count( $form_id, $quantity );
535
}
536
537
538
/**
539
 * Record Donation In Log
540
 *
541
 * Stores log information for a donation.
542
 *
543
 * @since 1.0
544
 * @global            $give_logs Give_Logging
545
 *
546
 * @param int         $give_form_id Give Form ID.
547
 * @param int         $payment_id   Payment ID.
548
 * @param bool|int    $price_id     Price ID, if any.
549
 * @param string|null $sale_date    The date of the sale.
550
 *
551
 * @return void
552
 */
553
function give_record_sale_in_log( $give_form_id = 0, $payment_id, $price_id = false, $sale_date = null ) {
554
	$backtrace = debug_backtrace();
555
556
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'give_record_donation_in_log', $backtrace );
557
558
	give_record_donation_in_log( $give_form_id, $payment_id, $price_id, $sale_date );
559
}
560
561
/**
562
 * Print Errors
563
 *
564
 * Prints all stored errors. Ensures errors show up on the appropriate form;
565
 * For use during donation process. If errors exist, they are returned.
566
 *
567
 * @since 1.0
568
 * @uses  give_get_errors()
569
 * @uses  give_clear_errors()
570
 *
571
 * @param int $form_id Form ID.
572
 *
573
 * @return void
574
 */
575
function give_print_errors( $form_id ) {
576
	$backtrace = debug_backtrace();
577
578
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'Give_Notice::print_frontend_errors', $backtrace );
579
580
	do_action( 'give_frontend_notices', $form_id );
581
}
582
583
/**
584
 * Give Output Error
585
 *
586
 * Helper function to easily output an error message properly wrapped; used commonly with shortcodes
587
 *
588
 * @since      1.3
589
 *
590
 * @param string $message  Message to store with the error.
591
 * @param bool   $echo     Flag to print or return output.
592
 * @param string $error_id ID of the error being set.
593
 *
594
 * @return   string  $error
595
 */
596
function give_output_error( $message, $echo = true, $error_id = 'warning' ) {
597
	$backtrace = debug_backtrace();
598
599
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'Give_Notice::print_frontend_notice', $backtrace );
600
601
	Give()->notices->print_frontend_notice( $message, $echo, $error_id );
602
}
603
604
605
/**
606
 * Get Donation Summary
607
 *
608
 * Retrieves the donation summary.
609
 *
610
 * @since       1.0
611
 *
612
 * @param array $purchase_data
613
 * @param bool  $email
614
 *
615
 * @return string
616
 */
617
function give_get_purchase_summary( $purchase_data, $email = true ) {
618
619
	$backtrace = debug_backtrace();
620
621
	_give_deprecated_function( __FUNCTION__, '1.8.12', 'give_payment_gateway_donation_summary', $backtrace );
622
623
	give_payment_gateway_donation_summary($purchase_data, $email);
624
625
}
626