Mail: Introduce a `pre_wp_mail` filter to allow short-circuiting the `wp_mail()` function without having to override the pluggable function.
Props DvanKooten, swissspidy, SergeyBiryukov, jtsternberg, ericlewis, Mte90, birgire, ayeshrajans Fixes #35069 Built from https://develop.svn.wordpress.org/trunk@49844 git-svn-id: http://core.svn.wordpress.org/trunk@49563 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5007f1ce13
commit
f0d44a3402
|
@ -161,12 +161,12 @@ if ( ! function_exists( 'wp_mail' ) ) :
|
|||
*
|
||||
* @global PHPMailer\PHPMailer\PHPMailer $phpmailer
|
||||
*
|
||||
* @param string|array $to Array or comma-separated list of email addresses to send message.
|
||||
* @param string $subject Email subject
|
||||
* @param string $message Message contents
|
||||
* @param string|array $headers Optional. Additional headers.
|
||||
* @param string|array $attachments Optional. Paths to files to attach.
|
||||
* @return bool Whether the email contents were sent successfully.
|
||||
* @param string|string[] $to Array or comma-separated list of email addresses to send message.
|
||||
* @param string $subject Email subject.
|
||||
* @param string $message Message contents.
|
||||
* @param string|string[] $headers Optional. Additional headers.
|
||||
* @param string|string[] $attachments Optional. Paths to files to attach.
|
||||
* @return bool Whether the email was sent successfully.
|
||||
*/
|
||||
function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) {
|
||||
// Compact the input, apply the filters, and extract them back out.
|
||||
|
@ -188,6 +188,32 @@ if ( ! function_exists( 'wp_mail' ) ) :
|
|||
*/
|
||||
$atts = apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) );
|
||||
|
||||
/**
|
||||
* Filters whether to preempt sending an email.
|
||||
*
|
||||
* Returning a non-null value will short-circuit {@see wp_mail()}, returning
|
||||
* that value instead. A boolean return value should be used to indicate whether
|
||||
* the email was successfully sent.
|
||||
*
|
||||
* @since 5.7.0
|
||||
*
|
||||
* @param null|bool $return Short-circuit return value.
|
||||
* @param array $atts {
|
||||
* Array of the `wp_mail()` arguments.
|
||||
*
|
||||
* @type string|string[] $to Array or comma-separated list of email addresses to send message.
|
||||
* @type string $subject Email subject.
|
||||
* @type string $message Message contents.
|
||||
* @type string|string[] $headers Additional headers.
|
||||
* @type string|string[] $attachments Paths to files to attach.
|
||||
* }
|
||||
*/
|
||||
$pre_wp_mail = apply_filters( 'pre_wp_mail', null, $atts );
|
||||
|
||||
if ( null !== $pre_wp_mail ) {
|
||||
return $pre_wp_mail;
|
||||
}
|
||||
|
||||
if ( isset( $atts['to'] ) ) {
|
||||
$to = $atts['to'];
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.7-alpha-49843';
|
||||
$wp_version = '5.7-alpha-49844';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue