diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index 0f984a7e58..7dee482170 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -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']; } diff --git a/wp-includes/version.php b/wp-includes/version.php index ff1704784b..a34a9299ff 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.