diff --git src/wp-includes/pluggable.php src/wp-includes/pluggable.php
index 8e24100..fc952c2 100644
|
|
function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() |
229 | 229 | */ |
230 | 230 | $atts = apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ); |
231 | 231 | |
| 232 | /** |
| 233 | * Filter whether to preempt sending an email. |
| 234 | * |
| 235 | * Passing a truthy value will effectively short-circuit {@see wp_mail()}, |
| 236 | * returning that value instead. |
| 237 | * |
| 238 | * @since 4.5.0 |
| 239 | * |
| 240 | * @param bool $return Short-circuit return value. |
| 241 | * @param array $args A compacted array of wp_mail() arguments, including the "to" email, |
| 242 | * subject, message, headers, and attachments values. |
| 243 | */ |
| 244 | $pre_wp_mail = apply_filters( 'pre_wp_mail', false, $atts ); |
| 245 | |
| 246 | if ( false !== $pre_wp_mail ) { |
| 247 | return $pre_wp_mail; |
| 248 | } |
| 249 | |
232 | 250 | if ( isset( $atts['to'] ) ) { |
233 | 251 | $to = $atts['to']; |
234 | 252 | } |
diff --git tests/phpunit/tests/mail.php tests/phpunit/tests/mail.php
index c8a435b..389f793 100644
|
|
class Tests_Mail extends WP_UnitTestCase { |
302 | 302 | |
303 | 303 | $this->assertNotContains( 'quoted-printable', $GLOBALS['phpmailer']->mock_sent[0]['header'] ); |
304 | 304 | } |
| 305 | |
| 306 | /** |
| 307 | * @ticket 35069 |
| 308 | */ |
| 309 | public function test_wp_mail_bail_early() { |
| 310 | $this->assertTrue( wp_mail( WP_TESTS_EMAIL, 'Foo', 'Bar' ) ); |
| 311 | |
| 312 | add_filter( 'pre_wp_mail', '__return_null' ); |
| 313 | $this->assertNull( wp_mail( WP_TESTS_EMAIL, 'Foo', 'Bar' ) ); |
| 314 | remove_filter( 'pre_wp_mail', '__return_null' ); |
| 315 | } |
305 | 316 | } |