WordPress.org

Make WordPress Core

Ticket #28059: 28059.2.diff

File 28059.2.diff, 1.9 KB (added by jesin, 5 years ago)

Update 28059.diff

  • src/wp-includes/pluggable.php

     
    230230 * @param string       $message     Message contents
    231231 * @param string|array $headers     Optional. Additional headers.
    232232 * @param string|array $attachments Optional. Files to attach.
     233 * @param string|array $embeds Optional. Files to embed inline.
    233234 * @return bool Whether the email contents were sent successfully.
    234235 */
    235 function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) {
     236function wp_mail( $to, $subject, $message, $headers = '', $attachments = array(), $embeds = array() ) {
    236237        // Compact the input, apply the filters, and extract them back out
    237238
    238239        /**
     
    241242         * @since 2.2.0
    242243         *
    243244         * @param array $args A compacted array of wp_mail() arguments, including the "to" email,
    244          *                    subject, message, headers, and attachments values.
     245         *                    subject, message, headers, attachments and embeds values.
    245246         */
    246         $atts = apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) );
     247        $atts = apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments', 'embeds' ) );
    247248
    248249        if ( isset( $atts['to'] ) ) {
    249250                $to = $atts['to'];
     
    268269        if ( ! is_array( $attachments ) ) {
    269270                $attachments = explode( "\n", str_replace( "\r\n", "\n", $attachments ) );
    270271        }
     272
     273        if ( ! is_array( $embeds ) ) {
     274                $embeds = explode( "\n", str_replace( "\r\n", "\n", $embeds ) );
     275        }
    271276        global $phpmailer;
    272277
    273278        // (Re)create it, if it's gone missing
     
    527532                }
    528533        }
    529534
     535        if ( !empty( $embeds ) ) {
     536                foreach ( $embeds as $embed ) {
     537                        try {
     538                                $phpmailer->addEmbeddedImage( $embed, basename( $embed ) );
     539                        } catch ( phpmailerException $e ) {
     540                                continue;
     541                        }
     542                }
     543        }
     544
    530545        /**
    531546         * Fires after PHPMailer is initialized.
    532547         *