Changeset 10792 for trunk/src/bp-core/classes/class-bp-email-recipient.php
- Timestamp:
- 05/19/2016 08:50:46 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/classes/class-bp-email-recipient.php
r10599 r10792 56 56 $name = sanitize_text_field( $name ); 57 57 58 // User ID, WP_User object. 59 if ( is_int( $email_or_user ) || is_object( $email_or_user ) ) { 60 $this->user_object = is_object( $email_or_user ) ? $email_or_user : get_user_by( 'id', $email_or_user ); 58 // User ID, email address or WP_User object. 59 if ( is_int( $email_or_user ) || ( is_string( $email_or_user ) && is_email( $email_or_user ) ) || is_object( $email_or_user ) ) { 60 // We already have a WP user. 61 if ( is_object( $email_or_user ) ) { 62 $this->user_object = $email_or_user; 61 63 62 if ( $this->user_object ) { 63 // This is escaped with esc_html in bp_core_get_user_displayname() 64 $name = wp_specialchars_decode( bp_core_get_user_displayname( $this->user_object->ID ), ENT_QUOTES ); 65 66 $this->address = $this->user_object->user_email; 67 $this->name = sanitize_text_field( $name ); 64 // Query for WP user by user ID. 65 } elseif ( is_int( $email_or_user ) ) { 66 $this->user_object = get_user_by( 'id', $email_or_user ); 68 67 } 69 68 70 // Array, address, and name. 69 // Set email address. 70 if ( empty( $this->user_object ) && is_email( $email_or_user ) ) { 71 $address = $email_or_user; 72 } 73 74 // Array or miscellaneous string. 71 75 } else { 72 76 if ( ! is_array( $email_or_user ) ) { … … 81 85 $name = current( $email_or_user ); 82 86 } 87 } 83 88 84 if ( is_email( $address ) ) { 85 $this->address = sanitize_email( $address ); 86 } 89 // Set address if we have one. 90 if ( ! empty( $address ) ) { 91 $this->address = sanitize_email( $address ); 92 } 87 93 94 // Still no user object; try to query user by email address. 95 if ( empty( $this->user_object ) ) { 96 $this->get_user( 'search-email' ); 97 } 98 99 // We have a user object; so set address and name from DB. 100 if ( $this->user_object ) { 101 // This is escaped with esc_html in bp_core_get_user_displayname() 102 $wp_name = wp_specialchars_decode( bp_core_get_user_displayname( $this->user_object->ID ), ENT_QUOTES ); 103 104 $this->address = $this->user_object->user_email; 105 $this->name = sanitize_text_field( $wp_name ); 106 107 } 108 109 // Custom name override. 110 if ( $name ) { 88 111 $this->name = $name; 89 112 }
Note: See TracChangeset
for help on using the changeset viewer.