Plugin Directory

Changeset 751406


Ignore:
Timestamp:
08/05/2013 04:46:45 AM (13 years ago)
Author:
Developdaly
Message:

1.1 changes

Location:
email/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • email/trunk/admin.php

    r751115 r751406  
    7171    register_post_type( 'email_log', $args );
    7272
     73    register_post_status( 'error', array(
     74        'label'         => _x( 'Error', 'email' ),
     75        'public'        => false,
     76        'label_count'   => _n_noop( 'Errors <span class="count">(%s)</span>', 'Errors <span class="count">(%s)</span>' )
     77    ) );
     78
    7379}
    7480
     
    140146            <?php
    141147
    142                 $actions = array( 'new', 'updated' );
     148                $actions = array( 'new', 'updated', 'deleted' );
    143149                $types = get_post_types();
    144150
  • email/trunk/email.php

    r751120 r751406  
    44 * Description: Email users with custom templates when certain actions happen, such as new posts, updated custom post types, deleted users.
    55 * Author: developdaly
    6  * Version: 1.0.3
     6 * Version: 1.1
    77 * Author URI: http://developdaly.com/
    88 * Text Domain: email
  • email/trunk/readme.txt

    r751120 r751406  
    44Requires at least: 3.5.2
    55Tested up to: 3.6
    6 Stable tag: 1.0.3
     6Stable tag: 1.1
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1212== Description ==
    1313
     14[**Contribute on Github**](https://github.com/developdaly/Email) | [**Report Bugs**](https://github.com/developdaly/Email/issues?labels=bug&milestone=&page=1&state=open)
     15
    1416This plugin allows you configure and reconfigure emails that are sent to specified users when certain things happen.
    1517
     
    1820* new post
    1921* updated post
     22* deleted post
    2023* (more coming soon)
    2124
     
    3437== Changelog ==
    3538
    36 = 1.0.3 =
    37 * Version bump
     39= 1.1 =
     40* Fixes issue where emails were not sending for the "new" action
     41* Fixes issue where emails were attempting to send (but failing in most cases) for all posts types, even if not specified by the rule
     42* Adds logging of failed emails
    3843
    3944= 1.0.2 =
  • email/trunk/router.php

    r751111 r751406  
    1919
    2020        $email_action = get_post_meta( $email->ID, 'email_action', true );
     21        $email_type = get_post_meta( $email->ID, 'email_type', true );
    2122
    22         if ( ($new_status != $old_status) && ( $email_action == 'new' ) && ( 'new' == $new_status ) ) {
    23             email_action( 'new', $post->ID, $email->ID );
     23        if( $email_type != $post->post_type )
     24            return;
     25
     26        if ( ($new_status != $old_status) && ( $email_action == 'new' ) && ( 'publish' == $new_status ) ) {
     27            email_action( 'new', $post->ID, $email->ID, $old_status, $new_status );
    2428        }
    2529
    26         if ( ($new_status == $old_status) &&  ( $email_action == 'updated' ) ) {
     30        elseif ( ($new_status == $old_status) &&  ( $email_action == 'updated' ) ) {
    2731            email_action( 'updated', $post->ID, $email->ID, $old_status, $new_status );
     32        }
     33
     34        elseif ( ($new_status != $old_status) && ( $email_action == 'deleted' ) && ( 'trash' == $new_status ) ) {
     35            email_action( 'deleted', $post->ID, $email->ID, $old_status, $new_status );
    2836        }
    2937
     
    99107    $mail = wp_mail( $users_to_list, $parsed_subject, $parsed_message, $headers );
    100108
     109    // Log successful email
    101110    if( $mail ) {
    102111
    103112        $args = array(
     113            'post_content'  => $parsed_message,
     114            'post_status'   => 'private',
    104115            'post_title'    => $parsed_subject,
    105             'post_type'     => 'email_log',
    106             'post_content'  => $parsed_message
     116            'post_type'     => 'email_log'
     117        );
     118        $log_id = wp_insert_post( $args );
     119
     120        foreach( $headers as $key => $val ) {
     121            update_post_meta( $log_id, $key, $val );
     122        }
     123    } else {
     124        // Log unsuccessful email
     125        $args = array(
     126            'post_content'  => $parsed_message,
     127            'post_status'   => 'error',
     128            'post_title'    => '[FAILED to send "'. $action .'" email] '. $parsed_subject,
     129            'post_type'     => 'email_log'
    107130        );
    108131        $log_id = wp_insert_post( $args );
Note: See TracChangeset for help on using the changeset viewer.