[wp-trac] [WordPress Trac] #35069: Allow short-circuiting wp_mail
WordPress Trac
noreply at wordpress.org
Fri Jan 8 03:15:02 UTC 2016
#35069: Allow short-circuiting wp_mail
--------------------------------------+------------------
Reporter: DvanKooten | Owner:
Type: enhancement | Status: new
Priority: low | Milestone: 4.5
Component: Mail | Version:
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests | Focuses:
--------------------------------------+------------------
Comment (by ericlewis):
Replying to [comment:5 swissspidy]:
> Perhaps a new filter could be used after the `wp_mail` filter?
>
> `$mail_short_circuit = apply_filters( 'wp_mail_short_circuit', false, …
)`
>
> If `true`, it means the mail was successfully sent/scheduled by the
function hooking into that. `false` means proceed with using PHPMailer.
I like this. It makes the control flow more obvious.
An alternative mailer should be allowed to fail and return its failure as
false,
[https://github.com/WordPress/WordPress/blob/4aa970e0e8b3c4b1f09b5bad72830872bb2c8832
/wp-includes/pluggable.php#L556 as wp_mail() does].
Perhaps we can filter on `null`. If anything non-null comes back, short-
circuit the function and return the filtered value.
We can use the `pre_*` filter naming convention here, since we'll be
returning the filtered value:
{{{
#!php
<?php
$pre_wp_mail = apply_filters( 'pre_wp_mail', null, $atts );
if ( ! is_null( $pre_wp_mail ) ) {
return $pre_wp_mail;
}
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35069#comment:12>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list