Make WordPress Core


Ignore:
Timestamp:
02/11/2020 09:41:26 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Privacy: Introduce filters for the headers of all the privacy-related e-mails:

  • wp_privacy_personal_data_email_headers
  • user_request_confirmed_email_headers
  • user_erasure_complete_email_headers
  • user_request_action_email_headers

Props xkon, garrett-eclipse, zaffarn, desrosj.
Fixes #44501.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/privacy/wpPrivacySendPersonalDataExportEmail.php

    r47144 r47279  
    254254
    255255    /**
     256     * The email headers should be filterable.
     257     *
     258     * @since 5.4.0
     259     *
     260     * @ticket 44501
     261     */
     262    public function test_email_headers_should_be_filterable() {
     263        add_filter( 'wp_privacy_personal_data_email_headers', array( $this, 'modify_email_headers' ) );
     264        wp_privacy_send_personal_data_export_email( self::$request_id );
     265
     266        $mailer = tests_retrieve_phpmailer_instance();
     267
     268        $this->assertContains( 'From: Tester <tester@example.com>', $mailer->get_sent()->header );
     269    }
     270
     271    /**
     272     * Filter callback to modify the headers of the email sent with a personal data export file.
     273     *
     274     * @since 5.4.0
     275     *
     276     * @param string|array $headers The email headers.
     277     * @return array       $headers The new email headers.
     278     */
     279    public function modify_email_headers( $headers ) {
     280        $headers = array(
     281            'From: Tester <tester@example.com>',
     282        );
     283
     284        return $headers;
     285    }
     286
     287    /**
    256288     * The email content should be filterable using the $email_data
    257289     *
Note: See TracChangeset for help on using the changeset viewer.