[wp-trac] [WordPress Trac] #35069: Allow short-circuiting wp_mail

WordPress Trac noreply at wordpress.org
Mon Dec 14 09:19:23 UTC 2015


#35069: Allow short-circuiting wp_mail
----------------------------------------+--------------------------
 Reporter:  DvanKooten                  |       Owner:
     Type:  enhancement                 |      Status:  new
 Priority:  normal                      |   Milestone:  4.5
Component:  Mail                        |     Version:
 Severity:  normal                      |  Resolution:
 Keywords:  has-patch needs-unit-tests  |     Focuses:  performance
----------------------------------------+--------------------------

Comment (by DvanKooten):

 @swissspidy The current code only uses the returned array values if they
 are actually set. Otherwise, it will use the passed arguments.

 {{{#!php
 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'];
 }
 }}}

 So emails can be disabled by emptying the `to` or `message` field but that
 will still run the entire function, setting up the `PHPMailer` object etc.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/35069#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list