Skip to content

Commit

Permalink
Introduce 'bpges_wp_mail_content' filter.
Browse files Browse the repository at this point in the history
This can be used to filter the content of emails before they
are sent by `wp_mail()`. Useful in cases where a plugin is overriding
`wp_mail()`, and you don't want to use the fallback plaintext content
provided by BPGES.

See #249.
  • Loading branch information
boonebgorges committed Apr 18, 2024
1 parent 3bef731 commit ba36aca
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion bp-activity-subscription-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,24 @@ function ass_send_email( $email_type, $to, $args ) {

$plaintext_content = ass_email_convert_html_to_plaintext( $args['content'] );

return wp_mail( $to, $args['subject'], $plaintext_content, $headers );
/**
* Filters email content when sent via wp_mail().
*
* In some cases, BPGES may detect that `wp_mail()` is in use because of
* a plugin that provides rich-text formatted email. In this case, users
* may wish to force the HTML BPGES content through, rather than the
* plaintext content.
*
* @since 4.2.3
*
* @param string $plaintext_content Converted-to-plaintext content.
* @param string $original_content Original BPGES message content.
* @param string $to To address.
* @param array $args Args passed to function.
*/
$wp_mail_content = apply_filters( 'bpges_wp_mail_content', $plaintext_content, $args['content'], $to, $args );

return wp_mail( $to, $args['subject'], $wp_mail_content, $headers );
}
}

Expand Down

0 comments on commit ba36aca

Please sign in to comment.