WordPress.org

Make WordPress Core

Ticket #7787: 7787.001.diff

File 7787.001.diff, 1.3 KB (added by AaronCampbell, 6 years ago)
  • trunk/wp-includes/pluggable.php

     
    253253 * @param string $subject Email subject 
    254254 * @param string $message Message contents 
    255255 * @param string|array $headers Optional. Additional headers. 
     256 * @param string|array $attachments Optional. Files to attach. 
    256257 * @return bool Whether the email contents were sent successfully. 
    257258 */ 
    258 function wp_mail( $to, $subject, $message, $headers = '' ) { 
     259function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) { 
    259260        // Compact the input, apply the filters, and extract them back out 
    260         extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers' ) ) ); 
     261        extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) ); 
    261262 
     263        if ( !is_array($attachments) ) 
     264                $attachments = explode( "\n", $attachments ); 
     265 
    262266        global $phpmailer; 
    263267 
    264268        // (Re)create it, if it's gone missing 
     
    406410                } 
    407411        } 
    408412 
     413        if ( !empty( $attachments ) ) { 
     414                foreach ( $attachments as $attachment ) { 
     415                        $phpmailer->addAttachment($attachment); 
     416                } 
     417        } 
     418 
    409419        do_action_ref_array( 'phpmailer_init', array( &$phpmailer ) ); 
    410420 
    411421        // Send!