PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13
1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 1.7.0.9 All 211 releases
← All changes | includes/users/charitable-user-functions.php +55 -15 1.6.9 → 1.8.13 View file →
@@ -4,10 +4,10 @@
4 4 *
5 5 * User related functions.
6 6 *
7 7 * @package Charitable/Functions/User
8 - * @author Eric Daams
9 - * @copyright Copyright (c) 2019, Studio 164a
8 + * @author David Bisset
9 + * @copyright Copyright (c) 2023, WP Charitable LLC
10 10 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
11 11 * @since 1.0.0
12 12 * @version 1.6.0
13 13 */
@@ -31,8 +31,9 @@
31 31 function charitable_get_user( $user_id, $force = false ) {
32 32 if ( is_a( $user_id, 'WP_User' ) ) {
33 33 $user_id = $user_id->ID;
34 34 }
35 +
35 36 $user = wp_cache_get( $user_id, 'charitable_user', $force );
36 37
37 38 if ( ! $user ) {
38 39 $user = new Charitable_User( $user_id );
@@ -52,21 +53,33 @@
52 53 *
53 54 * @return string[]
54 55 */
55 56 function charitable_get_user_mapped_keys() {
56 - return apply_filters( 'charitable_donor_mapped_keys', array(
57 - 'email' => 'user_email',
58 - 'company' => 'donor_company',
59 - 'address' => 'donor_address',
60 - 'address_2' => 'donor_address_2',
61 - 'city' => 'donor_city',
62 - 'state' => 'donor_state',
63 - 'postcode' => 'donor_postcode',
64 - 'zip' => 'donor_postcode',
65 - 'country' => 'donor_country',
66 - 'phone' => 'donor_phone',
67 - 'user_description' => 'description',
68 - ) );
57 + /**
58 + * Filter the mapping of shorthand keys to meta keys.
59 + *
60 + * The meta keys are used in the wp_usermeta table.
61 + *
62 + * @since 1.0.0
63 + *
64 + * @param array $keys User meta keys.
65 + */
66 + return apply_filters(
67 + 'charitable_donor_mapped_keys',
68 + array(
69 + 'email' => 'user_email',
70 + 'company' => 'donor_company',
71 + 'address' => 'donor_address',
72 + 'address_2' => 'donor_address_2',
73 + 'city' => 'donor_city',
74 + 'state' => 'donor_state',
75 + 'postcode' => 'donor_postcode',
76 + 'zip' => 'donor_postcode',
77 + 'country' => 'donor_country',
78 + 'phone' => 'donor_phone',
79 + 'user_description' => 'description',
80 + )
81 + );
69 82 }
70 83
71 84 /**
72 85 * Returns a list of the core user keys.
@@ -187,4 +200,31 @@
187 200 */
188 201 function charitable_get_donor_id_by_email( $email ) {
189 202 return charitable_get_table( 'donors' )->get_donor_id_by_email( $email );
190 203 }
204 +
205 +/**
206 + * Checks to see if the specified email address has a Gravatar image.
207 + *
208 + * @param $email The email of the address of the user to check
209 + * @return boolean
210 + * @since 1.0.2
211 + */
212 +function charitable_user_has_gravatar( $email ) {
213 + $hash_key = md5( strtolower( trim( $email ) ) );
214 + $has_gravatar = wp_cache_get( $hash_key, 'default', false, $uncached );
215 +
216 + if ( $uncached === $has_gravatar ) {
217 + if ( is_ssl() ) {
218 + $url = sprintf( 'https://secure.gravatar.com/avatar/%s?d=404', $hash_key );
219 + } else {
220 + $url = sprintf( 'http://www.gravatar.com/avatar/%s?d=404', $hash_key );
221 + }
222 +
223 + $response = wp_remote_get( $url );
224 + $has_gravatar = 200 == wp_remote_retrieve_response_code( $response );
225 +
226 + wp_cache_set( $hash_key, $has_gravatar, '', 60 * 5 );
227 + }
228 +
229 + return $has_gravatar;
230 +}