Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
03/06/2019 04:31:35 PM (7 years ago)
Author:
boonebgorges
Message:

Emails: Improve performance when setting Reply-To and From headers.

The new BP_Email_Participant framework allows the Reply-To and From email
headers to be set without requiring an empty and potentially expensive WP
user lookup.

Fixes #8003.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/classes/class-bp-email-recipient.php

    r10792 r12353  
    1515 * @since 2.5.0
    1616 */
    17 class BP_Email_Recipient {
    18 
    19     /**
    20      * Recipient's email address.
    21      *
    22      * @since 2.5.0
    23      *
    24      * @var string
    25      */
    26     protected $address = '';
    27 
    28     /**
    29      * Recipient's name.
    30      *
    31      * @since 2.5.0
    32      *
    33      * @var string
    34      */
    35     protected $name = '';
     17class BP_Email_Recipient extends BP_Email_Participant {
    3618
    3719    /**
     
    8971        // Set address if we have one.
    9072        if ( ! empty( $address ) ) {
    91             $this->address = sanitize_email( $address );
     73            $this->set_address( sanitize_email( $address ) );
    9274        }
    9375
     
    10284            $wp_name = wp_specialchars_decode( bp_core_get_user_displayname( $this->user_object->ID ), ENT_QUOTES );
    10385
    104             $this->address = $this->user_object->user_email;
    105             $this->name    = sanitize_text_field( $wp_name );
     86            $this->set_address( $this->user_object->user_email );
     87            $this->set_name( $wp_name );
    10688
    10789        }
     
    10991        // Custom name override.
    11092        if ( $name ) {
    111             $this->name = $name;
     93            $this->set_name( $name );
    11294        }
    11395
     
    133115     */
    134116    public function get_address() {
     117        $address = parent::get_address();
    135118
    136119        /**
     
    139122         * @since 2.5.0
    140123         *
    141          * @param string $address Recipient's address.
    142          * @param BP_Email $recipient $this Current instance of the email recipient class.
     124         * @param string             $address  Recipient's address.
     125         * @param BP_Email_Recipient $recipient Current instance of the email recipient class.
    143126         */
    144         return apply_filters( 'bp_email_recipient_get_address', $this->address, $this );
     127        return apply_filters( 'bp_email_recipient_get_address', $address, $this );
    145128    }
    146129
     
    153136     */
    154137    public function get_name() {
     138        $name = parent::get_name();
    155139
    156140        /**
     
    159143         * @since 2.5.0
    160144         *
    161          * @param string $name Recipient's name.
    162          * @param BP_Email $recipient $this Current instance of the email recipient class.
     145         * @param string             $name      Recipient's name.
     146         * @param BP_Email_Recipient $recipient Current instance of the email recipient class.
    163147         */
    164         return apply_filters( 'bp_email_recipient_get_name', $this->name, $this );
     148        return apply_filters( 'bp_email_recipient_get_name', $name, $this );
    165149    }
    166150
Note: See TracChangeset for help on using the changeset viewer.