diff --git src/wp-includes/pluggable.php src/wp-includes/pluggable.php
index e5b3e9f..978ae12 100644
|
|
|
if ( ! function_exists( 'wp_mail' ) ) : |
| 185 | 185 | */ |
| 186 | 186 | $atts = apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ); |
| 187 | 187 | |
| | 188 | /** |
| | 189 | * Filter whether to preempt sending an email. |
| | 190 | * |
| | 191 | * Passing a non-null value will effectively short-circuit {@see wp_mail()}, |
| | 192 | * returning that value instead. |
| | 193 | * |
| | 194 | * @since 5.0.0 |
| | 195 | * |
| | 196 | * @param null|bool $return Short-circuit return value. |
| | 197 | * @param array $atts A compacted array of `wp_mail()` arguments, including the "to" email, |
| | 198 | * subject, message, headers, and attachments values. |
| | 199 | */ |
| | 200 | $pre_wp_mail = apply_filters( 'pre_wp_mail', null, $atts ); |
| | 201 | |
| | 202 | if ( null !== $pre_wp_mail ) { |
| | 203 | return $pre_wp_mail; |
| | 204 | } |
| | 205 | |
| 188 | 206 | if ( isset( $atts['to'] ) ) { |
| 189 | 207 | $to = $atts['to']; |
| 190 | 208 | } |
diff --git tests/phpunit/tests/mail.php tests/phpunit/tests/mail.php
index 9516151..494c38a 100644
|
|
|
class Tests_Mail extends WP_UnitTestCase { |
| 391 | 391 | $this->assertEquals( 'wp_mail_failed', $call_args[0]->get_error_code() ); |
| 392 | 392 | $this->assertEquals( $expected_error_data, $call_args[0]->get_error_data() ); |
| 393 | 393 | } |
| | 394 | |
| | 395 | /** |
| | 396 | * Test for bailing out of wp_mail() early. |
| | 397 | * |
| | 398 | * @ticket 35069 |
| | 399 | */ |
| | 400 | public function test_wp_mail_bail_early() { |
| | 401 | $this->assertTrue( wp_mail( WP_TESTS_EMAIL, 'Foo', 'Bar' ) ); |
| | 402 | |
| | 403 | add_filter( 'pre_wp_mail', '__return_false' ); |
| | 404 | $result = wp_mail( WP_TESTS_EMAIL, 'Foo', 'Bar' ); |
| | 405 | remove_filter( 'pre_wp_mail', '__return_false' ); |
| | 406 | |
| | 407 | $this->assertFalse( $result ); |
| | 408 | } |
| 394 | 409 | } |