From 8e98541d5f735ec11a03b8ba4a0cb05e7bfa584a Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Thu, 15 May 2014 06:17:15 +0000 Subject: [PATCH] Eliminate the use of `extract()` in `wp_mail()`. Check the filtered array for each value before re-setting variables. See #22400. Built from https://develop.svn.wordpress.org/trunk@28425 git-svn-id: http://core.svn.wordpress.org/trunk@28252 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/pluggable.php | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index d5a680737b..c51e5b6d2d 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -233,11 +233,31 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() * @param array $args A compacted array of wp_mail() arguments, including the "to" email, * subject, message, headers, and attachments values. */ - extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) ); + $atts = apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ); - if ( !is_array($attachments) ) + if ( isset( $atts['to'] ) ) { + $to = $atts['to']; + } + + if ( isset( $atts['subject'] ) ) { + $subject = $atts['subject']; + } + + if ( isset( $atts['message'] ) ) { + $message = $atts['message']; + } + + if ( isset( $atts['headers'] ) ) { + $headers = $atts['headers']; + } + + if ( isset( $atts['attachments'] ) ) { + $attachments = $atts['attachments']; + } + + if ( ! is_array( $attachments ) ) { $attachments = explode( "\n", str_replace( "\r\n", "\n", $attachments ) ); - + } global $phpmailer; // (Re)create it, if it's gone missing