WordPress.org

Make WordPress Core


Ignore:
Timestamp:
12/20/2020 03:07:23 PM (4 weeks ago)
Author:
johnbillion
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/mail.php

    r48937 r49844  
    416416        $this->assertTrue( $phpmailer->validateAddress( 'foo@192.168.1.1' ), 'Assert PHPMailer accepts IP address email addresses' );
    417417    }
     418
     419    /**
     420     * Test for short-circuiting wp_mail().
     421     *
     422     * @ticket 35069
     423     */
     424    public function test_wp_mail_can_be_shortcircuited() {
     425        $result1 = wp_mail( WP_TESTS_EMAIL, 'Foo', 'Bar' );
     426
     427        add_filter( 'pre_wp_mail', '__return_false' );
     428        $result2 = wp_mail( WP_TESTS_EMAIL, 'Foo', 'Bar' );
     429        remove_filter( 'pre_wp_mail', '__return_false' );
     430
     431        $this->assertTrue( $result1 );
     432        $this->assertFalse( $result2 );
     433    }
    418434}
Note: See TracChangeset for help on using the changeset viewer.