Completed
Push — issues/1796 ( fe0f55...71eafd )
by Ravinder
17:33
created

deprecated-functions.php ➔ _give_load_deprecated_global_params()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 24 and the first side effect is on line 16.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
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
function _give_load_deprecated_global_params( $give_object ) {
0 ignored issues
show
Unused Code introduced by
The parameter $give_object is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
25
	$GLOBALS['give_logs'] = Give()->logs;
26
}
27
28
add_action( 'give_init', '_give_load_deprecated_global_params' );
29
30
31
/**
32
 * Checks if Guest checkout is enabled for a particular donation form
33
 *
34
 * @since      1.0
35
 * @deprecated 1.4.1
36
 *
37
 * @param int $form_id
38
 *
39
 * @return bool $ret True if guest checkout is enabled, false otherwise
40
 */
41
function give_no_guest_checkout( $form_id ) {
42
43
	$backtrace = debug_backtrace();
44
45
	_give_deprecated_function( __FUNCTION__, '1.4.1', null, $backtrace );
46
47
	$ret = give_get_meta( $form_id, '_give_logged_in_only', true );
48
49
	return (bool) apply_filters( 'give_no_guest_checkout', give_is_setting_enabled( $ret ) );
50
}
51
52
53
/**
54
 * Default Log Views
55
 *
56
 * @since      1.0
57
 * @deprecated 1.8
58
 * @return array $views Log Views
59
 */
60
function give_log_default_views() {
61
62
	$backtrace = debug_backtrace();
63
64
	_give_deprecated_function( __FUNCTION__, '1.8', null, $backtrace );
65
66
	$views = array(
67
		'sales'          => __( 'Donations', 'give' ),
68
		'gateway_errors' => __( 'Payment Errors', 'give' ),
69
		'api_requests'   => __( 'API Requests', 'give' ),
70
	);
71
72
	$views = apply_filters( 'give_log_views', $views );
73
74
	return $views;
75
}
76
77
/**
78
 * Donation form validate agree to "Terms and Conditions".
79
 *
80
 * @since      1.0
81
 * @deprecated 1.8.8
82
 */
83
function give_purchase_form_validate_agree_to_terms() {
84
85
	$backtrace = debug_backtrace();
86
87
	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_agree_to_terms', $backtrace );
88
89
	// Call new renamed function.
90
	give_donation_form_validate_agree_to_terms();
91
92
}
93
94
/**
95
 * Donation Form Validate Logged In User.
96
 *
97
 * @since      1.0
98
 * @deprecated 1.8.8
99
 */
100
function give_purchase_form_validate_logged_in_user() {
101
102
	$backtrace = debug_backtrace();
103
104
	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_logged_in_user', $backtrace );
105
106
	// Call new renamed function.
107
	give_donation_form_validate_logged_in_user();
108
109
}
110
111
/**
112
 * Donation Form Validate Logged In User.
113
 *
114
 * @since      1.0
115
 * @deprecated 1.8.8
116
 */
117
function give_purchase_form_validate_gateway() {
118
119
	$backtrace = debug_backtrace();
120
121
	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_gateway', $backtrace );
122
123
	// Call new renamed function.
124
	give_donation_form_validate_gateway();
125
126
}
127
128
/**
129
 * Donation Form Validate Fields.
130
 *
131
 * @since      1.0
132
 * @deprecated 1.8.8
133
 */
134
function give_purchase_form_validate_fields() {
135
136
	$backtrace = debug_backtrace();
137
138
	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_fields', $backtrace );
139
140
	// Call new renamed function.
141
	give_donation_form_validate_fields();
142
143
}
144
145
/**
146
 * Validates the credit card info.
147
 *
148
 * @since      1.0
149
 * @deprecated 1.8.8
150
 */
151
function give_purchase_form_validate_cc() {
152
153
	$backtrace = debug_backtrace();
154
155
	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_cc', $backtrace );
156
157
	// Call new renamed function.
158
	give_donation_form_validate_cc();
159
160
}
161
162
/**
163
 * Validates the credit card info.
164
 *
165
 * @since      1.0
166
 * @deprecated 1.8.8
167
 */
168
function give_get_purchase_cc_info() {
169
170
	$backtrace = debug_backtrace();
171
172
	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_get_donation_cc_info', $backtrace );
173
174
	// Call new renamed function.
175
	give_get_donation_cc_info();
176
177
}
178
179
180
/**
181
 * Validates the credit card info.
182
 *
183
 * @since      1.0
184
 * @deprecated 1.8.8
185
 *
186
 * @param int    $zip
187
 * @param string $country_code
188
 */
189
function give_purchase_form_validate_cc_zip( $zip = 0, $country_code = '' ) {
190
191
	$backtrace = debug_backtrace();
192
193
	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_cc_zip', $backtrace );
194
195
	// Call new renamed function.
196
	give_donation_form_validate_cc_zip( $zip, $country_code );
197
198
}
199
200
/**
201
 * Donation form validate user login.
202
 *
203
 * @since      1.0
204
 * @deprecated 1.8.8
205
 */
206
function give_purchase_form_validate_user_login() {
207
208
	$backtrace = debug_backtrace();
209
210
	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_user_login', $backtrace );
211
212
	// Call new renamed function.
213
	give_donation_form_validate_user_login();
214
215
}
216
217
/**
218
 * Donation Form Validate Guest User
219
 *
220
 * @since      1.0
221
 * @deprecated 1.8.8
222
 */
223
function give_purchase_form_validate_guest_user() {
224
225
	$backtrace = debug_backtrace();
226
227
	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_guest_user', $backtrace );
228
229
	// Call new renamed function.
230
	give_donation_form_validate_guest_user();
231
232
}
233
234
/**
235
 * Donate Form Validate New User
236
 *
237
 * @since      1.0
238
 * @deprecated 1.8.8
239
 */
240
function give_purchase_form_validate_new_user() {
241
242
	$backtrace = debug_backtrace();
243
244
	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_donation_form_validate_new_user', $backtrace );
245
246
	// Call new renamed function.
247
	give_donation_form_validate_new_user();
248
249
}
250
251
252
/**
253
 * Get Donation Form User
254
 *
255
 * @since      1.0
256
 * @deprecated 1.8.8
257
 *
258
 * @param array $valid_data
259
 */
260
function give_get_purchase_form_user( $valid_data = array() ) {
261
262
	$backtrace = debug_backtrace();
263
264
	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_get_donation_form_user', $backtrace );
265
266
	// Call new renamed function.
267
	give_get_donation_form_user( $valid_data );
268
269
}
270
271
/**
272
 * Give Checkout Button.
273
 *
274
 * Renders the button on the Checkout.
275
 *
276
 * @since      1.0
277
 * @deprecated 1.8.8
278
 *
279
 * @param  int $form_id The form ID.
280
 *
281
 * @return string
282
 */
283
function give_checkout_button_purchase( $form_id ) {
284
	$backtrace = debug_backtrace();
285
286
	_give_deprecated_function( __FUNCTION__, '1.8.8', 'give_get_donation_form_submit_button', $backtrace );
287
288
	return give_get_donation_form_submit_button( $form_id );
289
290
}
291
292
/**
293
 * Get the donor ID associated with a payment.
294
 *
295
 * @since 1.0
296
 *
297
 * @param int $payment_id Payment ID.
298
 *
299
 * @return int $customer_id Customer ID.
300
 */
301
function give_get_payment_customer_id( $payment_id ) {
302
303
	$backtrace = debug_backtrace();
304
305
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'give_get_payment_donor_id', $backtrace );
306
307
	return give_get_payment_donor_id( $payment_id );
308
}
309
310
311
/**
312
 * Get Total Donations.
313
 *
314
 * @since  1.0
315
 *
316
 * @return int $count Total sales.
317
 */
318
function give_get_total_sales() {
319
320
	$backtrace = debug_backtrace();
321
322
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'give_get_total_donations', $backtrace );
323
324
	return give_get_total_donations();
325
}
326
327
328
/**
329
 * Count number of donations of a donor.
330
 *
331
 * Returns total number of donations a donor has made.
332
 *
333
 * @access      public
334
 * @since       1.0
335
 *
336
 * @param       int|string $user The ID or email of the donor.
337
 *
338
 * @return      int The total number of donations
339
 */
340
function give_count_purchases_of_customer( $user = null ) {
341
342
	$backtrace = debug_backtrace();
343
344
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'give_count_donations_of_donor', $backtrace );
345
346
	return give_count_donations_of_donor( $user );
347
}
348
349
350
/**
351
 * Get Donation Status for User.
352
 *
353
 * Retrieves the donation count and the total amount spent for a specific user.
354
 *
355
 * @access      public
356
 * @since       1.0
357
 *
358
 * @param       int|string $user The ID or email of the donor to retrieve stats for.
359
 *
360
 * @return      array
361
 */
362
function give_get_purchase_stats_by_user( $user = '' ) {
363
364
	$backtrace = debug_backtrace();
365
366
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'give_get_donation_stats_by_user', $backtrace );
367
368
	return give_get_donation_stats_by_user( $user );
369
370
}
371
372
/**
373
 * Get Users Donations
374
 *
375
 * Retrieves a list of all donations by a specific user.
376
 *
377
 * @since  1.0
378
 *
379
 * @param int    $user   User ID or email address
380
 * @param int    $number Number of donations to retrieve
381
 * @param bool   $pagination
382
 * @param string $status
383
 *
384
 * @return bool|object List of all user donations
0 ignored issues
show
Documentation introduced by
Should the return type not be false|array?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
385
 */
386
function give_get_users_purchases( $user = 0, $number = 20, $pagination = false, $status = 'complete' ) {
387
388
	$backtrace = debug_backtrace();
389
390
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'give_get_users_donations', $backtrace );
391
392
	return give_get_users_donations( $user, $number, $pagination, $status );
393
394
}
395
396
397
/**
398
 * Has donations
399
 *
400
 * Checks to see if a user has donated to at least one form.
401
 *
402
 * @access      public
403
 * @since       1.0
404
 *
405
 * @param       int $user_id The ID of the user to check.
406
 *
407
 * @return      bool True if has donated, false other wise.
408
 */
409
function give_has_purchases( $user_id = null ) {
410
411
	$backtrace = debug_backtrace();
412
413
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'give_has_donations', $backtrace );
414
415
	return give_has_donations( $user_id );
416
}
417
418
/**
419
 * Counts the total number of donors.
420
 *
421
 * @access        public
422
 * @since         1.0
423
 *
424
 * @return        int The total number of donors.
425
 */
426
function give_count_total_customers() {
427
	$backtrace = debug_backtrace();
428
429
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'give_count_total_donors', $backtrace );
430
431
	return give_count_total_donors();
432
}
433
434
/**
435
 * Calculates the total amount spent by a user.
436
 *
437
 * @access      public
438
 * @since       1.0
439
 *
440
 * @param       int|string $user The ID or email of the donor.
441
 *
442
 * @return      float The total amount the user has spent
443
 */
444
function give_purchase_total_of_user( $user = null ) {
445
446
	$backtrace = debug_backtrace();
447
448
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'give_donation_total_of_user', $backtrace );
449
450
	return give_donation_total_of_user( $user );
451
}
452
453
/**
454
 * Deletes a Donation
455
 *
456
 * @since  1.0
457
 *
458
 * @param  int  $payment_id      Payment ID (default: 0).
459
 * @param  bool $update_customer If we should update the customer stats (default:true).
460
 *
461
 * @return void
462
 */
463
function give_delete_purchase( $payment_id = 0, $update_customer = true ) {
464
465
	$backtrace = debug_backtrace();
466
467
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'give_delete_donation', $backtrace );
468
469
	give_delete_donation( $payment_id, $update_customer );
470
471
}
472
473
474
/**
475
 * Undo Donation
476
 *
477
 * Undoes a donation, including the decrease of donations and earning stats.
478
 * Used for when refunding or deleting a donation.
479
 *
480
 * @since  1.0
481
 *
482
 * @param  int|bool $form_id    Form ID (default: false).
483
 * @param  int      $payment_id Payment ID.
484
 *
485
 * @return void
486
 */
487
function give_undo_purchase( $form_id = false, $payment_id ) {
0 ignored issues
show
Unused Code introduced by
The parameter $form_id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
488
489
	$backtrace = debug_backtrace();
490
491
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'give_undo_donation', $backtrace );
492
493
	give_undo_donation( $payment_id );
494
}
495
496
497
/**
498
 * Trigger a Donation Deletion.
499
 *
500
 * @since 1.0
501
 *
502
 * @param array $data Arguments passed.
503
 *
504
 * @return void
505
 */
506
function give_trigger_purchase_delete( $data ) {
507
	$backtrace = debug_backtrace();
508
509
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'give_trigger_donation_delete', $backtrace );
510
511
	give_trigger_donation_delete( $data );
512
}
513
514
515
/**
516
 * Increases the donation total count of a donation form.
517
 *
518
 * @since 1.0
519
 *
520
 * @param int $form_id  Give Form ID
521
 * @param int $quantity Quantity to increase donation count by
522
 *
523
 * @return bool|int
0 ignored issues
show
Documentation introduced by
Should the return type not be boolean|integer|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
524
 */
525
function give_increase_purchase_count( $form_id = 0, $quantity = 1 ) {
526
	$backtrace = debug_backtrace();
527
528
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'give_increase_donation_count', $backtrace );
529
530
	give_increase_donation_count( $form_id, $quantity );
531
}
532
533
534
/**
535
 * Record Donation In Log
536
 *
537
 * Stores log information for a donation.
538
 *
539
 * @since 1.0
540
 *
541
 * @param int         $give_form_id Give Form ID.
542
 * @param int         $payment_id   Payment ID.
543
 * @param bool|int    $price_id     Price ID, if any.
544
 * @param string|null $sale_date    The date of the sale.
545
 *
546
 * @return void
547
 */
548
function give_record_sale_in_log( $give_form_id = 0, $payment_id, $price_id = false, $sale_date = null ) {
549
	$backtrace = debug_backtrace();
550
551
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'give_record_donation_in_log', $backtrace );
552
553
	give_record_donation_in_log( $give_form_id, $payment_id, $price_id, $sale_date );
554
}
555
556
/**
557
 * Print Errors
558
 *
559
 * Prints all stored errors. Ensures errors show up on the appropriate form;
560
 * For use during donation process. If errors exist, they are returned.
561
 *
562
 * @since 1.0
563
 * @uses  give_get_errors()
564
 * @uses  give_clear_errors()
565
 *
566
 * @param int $form_id Form ID.
567
 *
568
 * @return void
569
 */
570
function give_print_errors( $form_id ) {
571
	$backtrace = debug_backtrace();
572
573
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'Give_Notice::print_frontend_errors', $backtrace );
574
575
	do_action( 'give_frontend_notices', $form_id );
576
}
577
578
/**
579
 * Give Output Error
580
 *
581
 * Helper function to easily output an error message properly wrapped; used commonly with shortcodes
582
 *
583
 * @since      1.3
584
 *
585
 * @param string $message  Message to store with the error.
586
 * @param bool   $echo     Flag to print or return output.
587
 * @param string $error_id ID of the error being set.
588
 *
589
 * @return   string  $error
0 ignored issues
show
Documentation introduced by
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
590
 */
591
function give_output_error( $message, $echo = true, $error_id = 'warning' ) {
592
	$backtrace = debug_backtrace();
593
594
	_give_deprecated_function( __FUNCTION__, '1.8.9', 'Give_Notice::print_frontend_notice', $backtrace );
595
596
	Give()->notices->print_frontend_notice( $message, $echo, $error_id );
597
}
598