diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index 2a53eab387..1880926874 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -253,11 +253,15 @@ if ( !function_exists( 'wp_mail' ) ) : * @param string $subject Email subject * @param string $message Message contents * @param string|array $headers Optional. Additional headers. + * @param string|array $attachments Optional. Files to attach. * @return bool Whether the email contents were sent successfully. */ -function wp_mail( $to, $subject, $message, $headers = '' ) { +function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) { // Compact the input, apply the filters, and extract them back out - extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers' ) ) ); + extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) ); + + if ( !is_array($attachments) ) + $attachments = explode( "\n", $attachments ); global $phpmailer; @@ -406,6 +410,13 @@ function wp_mail( $to, $subject, $message, $headers = '' ) { } } + error_log($attachments); + if ( !empty( $attachments ) ) { + foreach ( $attachments as $attachment ) { + $phpmailer->AddAttachment($attachment); + } + } + do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) ); // Send!