Plugin Directory

Changeset 1663164


Ignore:
Timestamp:
05/23/2017 01:27:01 PM (9 years ago)
Author:
marushu
Message:

change send mail each address

File:
1 edited

Legend:

Unmodified
Added
Removed
  • post-notifier/trunk/post-notifier.php

    r1324805 r1663164  
    117117        $post_content = wp_strip_all_tags( $post->post_content );
    118118        $post_content = wp_trim_words( $post_content, 50, '…' );
    119 
    120         foreach ( (array) $emails as $email ) {
    121             if ( ! is_email( $email ) ) {
    122                 return;
    123             }
    124 
    125             $to[]      = sprintf( '%s', sanitize_email( $email ) );
    126             $headers[] = 'Bcc:' . sanitize_email( $email );
    127         }
    128119        $subject = sprintf( '%s' . PHP_EOL, trim( $title ) );
    129120        $message .= sprintf( '%s' . PHP_EOL, trim( $permalink ) );
    130121        $headers[] = 'From:' . sanitize_email( $sender_email );
    131122
    132         /**
    133          * Check post status if post status is 'publish' is no fire
    134          */
    135         if ( in_array( $post->post_type, $post_types, true ) && 'publish' === $new_status && 'publish' !== $old_status ) {
    136 
    137             add_filter( 'wp_mail_from', function( $sender_email ) {
    138                 return sanitize_email( $sender_email );
    139             } );
    140 
    141             wp_mail( $to, $subject, $message, $headers, $attachments );
    142 
    143         }
     123        foreach ( (array) $emails as $email ) {
     124
     125            if ( ! is_email( $email ) ) {
     126                return;
     127            }
     128
     129            $to[]      = sprintf( '%s', sanitize_email( $email ) );
     130
     131            /**
     132             * Check post status if post status is 'publish' is no fire
     133             */
     134            if ( in_array( $post->post_type, $post_types, true ) && 'publish' === $new_status && 'publish' !== $old_status ) {
     135
     136                add_filter( 'wp_mail_from', function( $sender_email ) {
     137                    return sanitize_email( $sender_email );
     138                } );
     139
     140                wp_mail( $to, $subject, $message, $headers, $attachments );
     141
     142            }
     143
     144        }
     145
    144146    }
    145147
Note: See TracChangeset for help on using the changeset viewer.