Completed
Push — issues/1781 ( da0482...cc8330 )
by Ravinder
17:50
created

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