<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[47279] trunk: Privacy: Introduce filters for the headers of all the privacy-related e-mails:</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/47279">47279</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/47279","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2020-02-11 21:41:26 +0000 (Tue, 11 Feb 2020)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>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 <a href="https://core.trac.wordpress.org/ticket/44501">#44501</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludesprivacytoolsphp">trunk/src/wp-admin/includes/privacy-tools.php</a></li>
<li><a href="#trunksrcwpincludesuserphp">trunk/src/wp-includes/user.php</a></li>
<li><a href="#trunktestsphpunittestsprivacywpPrivacySendErasureFulfillmentNotificationphp">trunk/tests/phpunit/tests/privacy/wpPrivacySendErasureFulfillmentNotification.php</a></li>
<li><a href="#trunktestsphpunittestsprivacywpPrivacySendPersonalDataExportEmailphp">trunk/tests/phpunit/tests/privacy/wpPrivacySendPersonalDataExportEmail.php</a></li>
<li><a href="#trunktestsphpunittestsprivacywpPrivacySendRequestConfirmationNotificationphp">trunk/tests/phpunit/tests/privacy/wpPrivacySendRequestConfirmationNotification.php</a></li>
<li><a href="#trunktestsphpunittestsuserwpSendUserRequestphp">trunk/tests/phpunit/tests/user/wpSendUserRequest.php</a></li>
<li><a href="#trunktestsphpunittestsuserphp">trunk/tests/phpunit/tests/user.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludesprivacytoolsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/privacy-tools.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/privacy-tools.php 2020-02-11 21:26:25 UTC (rev 47278)
+++ trunk/src/wp-admin/includes/privacy-tools.php 2020-02-11 21:41:26 UTC (rev 47279)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -658,8 +658,35 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $content = str_replace( '###SITENAME###', $site_name, $content );
</span><span class="cx" style="display: block; padding: 0 10px"> $content = str_replace( '###SITEURL###', esc_url_raw( $site_url ), $content );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $mail_success = wp_mail( $request_email, $subject, $content );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $headers = '';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Filters the headers of the email sent with a personal data export file.
+ *
+ * @since 5.4.0
+ *
+ * @param string|array $headers The email headers.
+ * @param string $subject The email subject.
+ * @param string $content The email content.
+ * @param int $request_id The request ID.
+ * @param array $email_data {
+ * Data relating to the account action email.
+ *
+ * @type WP_User_Request $request User request object.
+ * @type int $expiration The time in seconds until the export file expires.
+ * @type string $expiration_date The localized date and time when the export file expires.
+ * @type string $message_recipient The address that the email will be sent to. Defaults
+ * to the value of `$request->email`, but can be changed
+ * by the `wp_privacy_personal_data_email_to` filter.
+ * @type string $export_file_url The export file URL.
+ * @type string $sitename The site name sending the mail.
+ * @type string $siteurl The site URL sending the mail.
+ * }
+ */
+ $headers = apply_filters( 'wp_privacy_personal_data_email_headers', $headers, $subject, $content, $request_id, $email_data );
+
+ $mail_success = wp_mail( $request_email, $subject, $content, $headers );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $switched_locale ) {
</span><span class="cx" style="display: block; padding: 0 10px"> restore_previous_locale();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpincludesuserphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/user.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/user.php 2020-02-11 21:26:25 UTC (rev 47278)
+++ trunk/src/wp-includes/user.php 2020-02-11 21:41:26 UTC (rev 47279)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3294,8 +3294,33 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> $subject = apply_filters( 'user_request_confirmed_email_subject', $subject, $email_data['sitename'], $email_data );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $email_sent = wp_mail( $email_data['admin_email'], $subject, $content );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $headers = '';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Filters the headers of the user request confirmation email.
+ *
+ * @since 5.4.0
+ *
+ * @param string|array $headers The email headers.
+ * @param string $subject The email subject.
+ * @param string $content The email content.
+ * @param int $request_id The request ID.
+ * @param array $email_data {
+ * Data relating to the account action email.
+ *
+ * @type WP_User_Request $request User request object.
+ * @type string $user_email The email address confirming a request
+ * @type string $description Description of the action being performed so the user knows what the email is for.
+ * @type string $manage_url The link to click manage privacy requests of this type.
+ * @type string $sitename The site name sending the mail.
+ * @type string $siteurl The site URL sending the mail.
+ * @type string $admin_email The administrator email receiving the mail.
+ * }
+ */
+ $headers = apply_filters( 'user_request_confirmed_email_headers', $headers, $subject, $content, $request_id, $email_data );
+
+ $email_sent = wp_mail( $email_data['admin_email'], $subject, $content, $headers );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $email_sent ) {
</span><span class="cx" style="display: block; padding: 0 10px"> update_post_meta( $request_id, '_wp_admin_notified', true );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3440,8 +3465,33 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $content = str_replace( '###PRIVACY_POLICY_URL###', $email_data['privacy_policy_url'], $content );
</span><span class="cx" style="display: block; padding: 0 10px"> $content = str_replace( '###SITEURL###', esc_url_raw( $email_data['siteurl'] ), $content );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $email_sent = wp_mail( $user_email, $subject, $content );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $headers = '';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Filters the headers of the data erasure fulfillment notification.
+ *
+ * @since 5.4.0
+ *
+ * @param string|array $headers The email headers.
+ * @param string $subject The email subject.
+ * @param string $content The email content.
+ * @param int $request_id The request ID.
+ * @param array $email_data {
+ * Data relating to the account action email.
+ *
+ * @type WP_User_Request $request User request object.
+ * @type string $message_recipient The address that the email will be sent to. Defaults
+ * to the value of `$request->email`, but can be changed
+ * by the `user_erasure_fulfillment_email_to` filter.
+ * @type string $privacy_policy_url Privacy policy URL.
+ * @type string $sitename The site name sending the mail.
+ * @type string $siteurl The site URL sending the mail.
+ * }
+ */
+ $headers = apply_filters( 'user_erasure_complete_email_headers', $headers, $subject, $content, $request_id, $email_data );
+
+ $email_sent = wp_mail( $user_email, $subject, $content, $headers );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $switched_locale ) {
</span><span class="cx" style="display: block; padding: 0 10px"> restore_previous_locale();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -3702,8 +3752,32 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> $subject = apply_filters( 'user_request_action_email_subject', $subject, $email_data['sitename'], $email_data );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $email_sent = wp_mail( $email_data['email'], $subject, $content );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $headers = '';
</ins><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * Filters the headers of the email sent when an account action is attempted.
+ *
+ * @since 5.4.0
+ *
+ * @param string|array $headers The email headers.
+ * @param string $subject The email subject.
+ * @param string $content The email content.
+ * @param int $request_id The request ID.
+ * @param array $email_data {
+ * Data relating to the account action email.
+ *
+ * @type WP_User_Request $request User request object.
+ * @type string $email The email address this is being sent to.
+ * @type string $description Description of the action being performed so the user knows what the email is for.
+ * @type string $confirm_url The link to click on to confirm the account action.
+ * @type string $sitename The site name sending the mail.
+ * @type string $siteurl The site URL sending the mail.
+ * }
+ */
+ $headers = apply_filters( 'user_request_action_email_headers', $headers, $subject, $content, $request_id, $email_data );
+
+ $email_sent = wp_mail( $email_data['email'], $subject, $content, $headers );
+
</ins><span class="cx" style="display: block; padding: 0 10px"> if ( $switched_locale ) {
</span><span class="cx" style="display: block; padding: 0 10px"> restore_previous_locale();
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsprivacywpPrivacySendErasureFulfillmentNotificationphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/privacy/wpPrivacySendErasureFulfillmentNotification.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/privacy/wpPrivacySendErasureFulfillmentNotification.php 2020-02-11 21:26:25 UTC (rev 47278)
+++ trunk/tests/phpunit/tests/privacy/wpPrivacySendErasureFulfillmentNotification.php 2020-02-11 21:41:26 UTC (rev 47279)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -257,6 +257,38 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * The email headers of the fulfillment notification should be filterable.
+ *
+ * @since 5.4.0
+ *
+ * @ticket 44501
+ */
+ public function test_email_headers_should_be_filterable() {
+ add_filter( 'user_erasure_complete_email_headers', array( $this, 'modify_email_headers' ) );
+ _wp_privacy_send_erasure_fulfillment_notification( self::$request_id );
+
+ $mailer = tests_retrieve_phpmailer_instance();
+
+ $this->assertContains( 'From: Tester <tester@example.com>', $mailer->get_sent()->header );
+ }
+
+ /**
+ * Filter callback that modifies the email headers of the data erasure fulfillment notification.
+ *
+ * @since 5.4.0
+ *
+ * @param string|array $headers The email headers.
+ * @return array $headers The new email headers.
+ */
+ public function modify_email_headers( $headers ) {
+ $headers = array(
+ 'From: Tester <tester@example.com>',
+ );
+
+ return $headers;
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * The function should not send an email when the request ID does not exist.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 44234
</span></span></pre></div>
<a id="trunktestsphpunittestsprivacywpPrivacySendPersonalDataExportEmailphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/privacy/wpPrivacySendPersonalDataExportEmail.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/privacy/wpPrivacySendPersonalDataExportEmail.php 2020-02-11 21:26:25 UTC (rev 47278)
+++ trunk/tests/phpunit/tests/privacy/wpPrivacySendPersonalDataExportEmail.php 2020-02-11 21:41:26 UTC (rev 47279)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -253,6 +253,38 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * The email headers should be filterable.
+ *
+ * @since 5.4.0
+ *
+ * @ticket 44501
+ */
+ public function test_email_headers_should_be_filterable() {
+ add_filter( 'wp_privacy_personal_data_email_headers', array( $this, 'modify_email_headers' ) );
+ wp_privacy_send_personal_data_export_email( self::$request_id );
+
+ $mailer = tests_retrieve_phpmailer_instance();
+
+ $this->assertContains( 'From: Tester <tester@example.com>', $mailer->get_sent()->header );
+ }
+
+ /**
+ * Filter callback to modify the headers of the email sent with a personal data export file.
+ *
+ * @since 5.4.0
+ *
+ * @param string|array $headers The email headers.
+ * @return array $headers The new email headers.
+ */
+ public function modify_email_headers( $headers ) {
+ $headers = array(
+ 'From: Tester <tester@example.com>',
+ );
+
+ return $headers;
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * The email content should be filterable using the $email_data
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 46303
</span></span></pre></div>
<a id="trunktestsphpunittestsprivacywpPrivacySendRequestConfirmationNotificationphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/privacy/wpPrivacySendRequestConfirmationNotification.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/privacy/wpPrivacySendRequestConfirmationNotification.php 2020-02-11 21:26:25 UTC (rev 47278)
+++ trunk/tests/phpunit/tests/privacy/wpPrivacySendRequestConfirmationNotification.php 2020-02-11 21:41:26 UTC (rev 47279)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -207,4 +207,42 @@
</span><span class="cx" style="display: block; padding: 0 10px"> return $email_text;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+ * The email headers should be filterable.
+ *
+ * @since 5.4.0
+ *
+ * @ticket 44501
+ */
+ public function test_email_headers_should_be_filterable() {
+ $email = 'export.request.from.unregistered.user@example.com';
+ $request_id = wp_create_user_request( $email, 'export_personal_data' );
+
+ _wp_privacy_account_request_confirmed( $request_id );
+
+ add_filter( 'user_request_confirmed_email_headers', array( $this, 'modify_email_headers' ) );
+ _wp_privacy_send_request_confirmation_notification( $request_id );
+ remove_filter( 'user_request_confirmed_email_headers', array( $this, 'modify_email_headers' ) );
+
+ $mailer = tests_retrieve_phpmailer_instance();
+
+ $this->assertContains( 'From: Tester <tester@example.com>', $mailer->get_sent()->header );
+ }
+
+ /**
+ * Filter callback that modifies the headers of the user request confirmation email.
+ *
+ * @since 5.4.0
+ *
+ * @param string|array $headers The email headers.
+ * @return array $headers The new email headers.
+ */
+ public function modify_email_headers( $headers ) {
+ $headers = array(
+ 'From: Tester <tester@example.com>',
+ );
+
+ return $headers;
+ }
+
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsuserwpSendUserRequestphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/user/wpSendUserRequest.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/user/wpSendUserRequest.php 2020-02-11 21:26:25 UTC (rev 47278)
+++ trunk/tests/phpunit/tests/user/wpSendUserRequest.php 2020-02-11 21:41:26 UTC (rev 47279)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -229,6 +229,40 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * The email headers should be filterable.
+ *
+ * @since 5.4.0
+ *
+ * @ticket 44501
+ */
+ public function test_email_headers_should_be_filterable() {
+ $request_id = wp_create_user_request( self::$test_user->user_email, 'remove_personal_data' );
+
+ add_filter( 'user_request_action_email_headers', array( $this, 'modify_email_headers' ) );
+ $result = wp_send_user_request( $request_id );
+
+ $mailer = tests_retrieve_phpmailer_instance();
+
+ $this->assertContains( 'From: Tester <tester@example.com>', $mailer->get_sent()->header );
+ }
+
+ /**
+ * Filter callback to modify the headers of the email sent when an account action is attempted.
+ *
+ * @since 5.4.0
+ *
+ * @param string|array $headers The email headers.
+ * @return array $headers The new email headers.
+ */
+ public function modify_email_headers( $headers ) {
+ $headers = array(
+ 'From: Tester <tester@example.com>',
+ );
+
+ return $headers;
+ }
+
+ /**
</ins><span class="cx" style="display: block; padding: 0 10px"> * The function should error when the email was not sent.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @ticket 43985
</span></span></pre></div>
<a id="trunktestsphpunittestsuserphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/user.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/user.php 2020-02-11 21:26:25 UTC (rev 47278)
+++ trunk/tests/phpunit/tests/user.php 2020-02-11 21:41:26 UTC (rev 47279)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1798,6 +1798,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Testing the `wp_privacy_additional_user_profile_data` filter works.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.4.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @ticket 47509
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> function test_filter_wp_privacy_additional_user_profile_data() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1881,6 +1883,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Filter callback to add additional profile data to the User Group on Export Requests.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.4.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @ticket 47509
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array $additional_profile_data The additional user data.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1902,6 +1906,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * This callback should generate a `_doing_it_wrong()`.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 5.4.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @ticket 47509
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @return array $additional_profile_data The additional user data.
</span></span></pre>
</div>
</div>
</body>
</html>