PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / DonorDashboards / Helpers / SanitizeProfileData.php

SanitizeProfileData.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at src/DonorDashboards/Helpers/SanitizeProfileData.php

96 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\DonorDashboards\Helpers;
4
5 /**
6 * Normalize format of location type lists.
7 * @since 2.10.0
8 */
9 class SanitizeProfileData
10 {
11
12 /**
13 * Sanitize int passed, and return 0 if something other than an integer was passed
14 *
15 * @since 2.10.0
16 *
17 * @param string $avatarId
18 *
19 * @return int
20 *
21 */
22 public static function sanitizeInt($avatarId)
23 {
24 if ( ! empty($avatarId)) {
25 return intval($avatarId);
26 } else {
27 return 0;
28 }
29 }
30
31 /**
32 * Sanitize array of addresses passed
33 *
34 * @since 2.10.0
35 *
36 * @param array $addresses
37 *
38 * @return array
39 *
40 */
41 public static function sanitizeAdditionalAddresses($addresses)
42 {
43 if ( ! empty($addresses)) {
44 return array_map([__CLASS__, 'sanitizeAddress'], $addresses);
45 } else {
46 return [];
47 }
48 }
49
50 /**
51 * Sanitize address object passed
52 *
53 * @since 2.10.0
54 *
55 * @param object $address
56 *
57 * @return object
58 *
59 */
60 public static function sanitizeAddress($address)
61 {
62 if ( ! empty($address)) {
63 foreach ($address as $key => $value) {
64 $address->{$key} = sanitize_text_field($value);
65 }
66
67 return $address;
68 } else {
69 return [];
70 }
71 }
72
73 /**
74 * Sanitize array of emails passed
75 *
76 * @since 2.10.0
77 *
78 * @param array $emails
79 *
80 * @return array
81 *
82 */
83 public static function sanitizeAdditionalEmails($emails)
84 {
85 if ( ! empty($emails)) {
86 foreach ($emails as $key => $value) {
87 $emails[$key] = sanitize_email($value);
88 }
89
90 return $emails;
91 } else {
92 return [];
93 }
94 }
95 }
96