Plugin Directory

Changeset 680651


Ignore:
Timestamp:
03/12/2013 05:38:57 PM (13 years ago)
Author:
TouchOfTech
Message:

Version 1.2 contains changes to the format of the email that is sent.

Location:
draft-notify
Files:
1 added
2 edited
2 copied

Legend:

Unmodified
Added
Removed
  • draft-notify/trunk/draft-notify.php

    r677289 r680651  
    55Description: When an author saves a post, it sends out an email based on the settings.  Either to a single email address, or to all users above a certain access level.  You can also select whether or not to send emails for revisions.
    66Author: Andrew Hallman
    7 Version: 1.0
     7Version: 1.2
    88Author URI: http://www.touchoftechnology.com
    99*/
     
    2222        $emailForRevisions = get_option('draftnotifyemailrevisions');
    2323   
     24                    // Author's first and last name are found in the metadata table.
    2425    $result = $wpdb->get_row("
    25         SELECT  post_status, post_title, user_login, display_name
    26         FROM    {$prefix}posts, {$prefix}users
     26        SELECT  post_status, post_title, post_modified,
     27                        user_login, display_name, user_email,
     28                        {$prefix}usermeta.meta_value as fname,
     29                        meta2.meta_value as lname
     30        FROM    {$prefix}posts, {$prefix}users
     31                            LEFT JOIN ({$prefix}usermeta) ON
     32                                    ({$prefix}usermeta.user_id = {$prefix}users.ID AND
     33                                     {$prefix}usermeta.meta_key = 'first_name' )
     34                            LEFT JOIN ({$prefix}usermeta as meta2) ON
     35                                    (meta2.user_id = {$prefix}users.ID AND
     36                                     meta2.meta_key = 'last_name' )
    2737        WHERE   {$prefix}posts.post_author = {$prefix}users.ID AND {$prefix}posts.ID = '$id' ");
    2838
     
    4858           
    4959            // also do the manual check for the autosave of the first draft. 
    50 //            settings_fields('draftnotify_options');
    51 //            do_settings_sections('draftnotify_options');
    5260            $alreadyEmailedList = get_option('draftnotifyemailedlist');
    5361            $emailedEx = explode("|", $alreadyEmailedList);
     
    6068            if($canEmail)
    6169            {
    62         $message = "A draft was created: '" . get_bloginfo('name') . "'\n";
    63         $message .= "Post Title: " . $result->post_title . "\n";
    64         $message .= "Author's Username: " . $result->user_login . "\n";
    65 
    66         //$message .= var_export($result, true);
    67 
     70        $message = "A draft was created: '" . get_bloginfo('name') . "'\n<br>";
     71        $message .= "Post Title: " . $result->post_title . "\n<br>";
     72        $message .= "Post Modified: " . $result->post_modified . "\n<br>";
     73        $message .= "Author's Username: " . $result->user_login . "\n<br>";
     74       
     75               
     76                $savedEmailPostLinkVal = get_option('draftnotifyemailpostlink');
     77                $savedEmailAuthorNameVal = get_option('draftnotifyemailauthorname');
     78                $savedEmailAuthorEmailAddressVal = get_option('draftnotifyemailauthoremail');
     79               
     80                if($savedEmailAuthorNameVal)
     81                {
     82                    $message .= "Author's Real Name: {$result->fname} {$result->lname }\n<br>";
     83                }
     84               
     85               
     86                if($savedEmailAuthorEmailAddressVal)
     87                {
     88                    $message .= "Author's Email Address: " . $result->user_email . "\n<br>";
     89                }
     90               
     91                if($savedEmailPostLinkVal)
     92                {
     93                    $message .= "\n<br>Link to Pending Posts: <a href='" . home_url('/') . "wp-admin/edit.php?post_status=pending&post_type=post' target='_blank'>here</a>\n<br>";
     94                }
     95               
    6896        $subject = "Draft on '" . get_bloginfo('name') . "'";
    6997
     
    84112        }
    85113       
    86         mail($recipient, $subject, $message);
     114                $headers  = 'MIME-Version: 1.0' . "\r\n";
     115                $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
     116        mail($recipient, $subject, $message, $headers);
    87117           
    88118                if(!in_array($id, $emailedEx))
     
    118148register_setting( 'draftnotify_options', 'draftnotifyemailrevisions' );
    119149register_setting( 'draftnotify_options', 'draftnotifyemailedlist' );
     150register_setting( 'draftnotify_options', 'draftnotifyemailpostlink' );
     151register_setting( 'draftnotify_options', 'draftnotifyemailauthorname' );
     152register_setting( 'draftnotify_options', 'draftnotifyemailauthoremail' );
    120153}
    121154
     
    168201</select></td>
    169202<td valign='top'>If you would like an email every time someones saves a revision to the draft, select Yes, otherwise, select NO and you'll only get an email the first time the draft is saved.</td>
    170 </tr>
    171 </table>";
     203</tr>";
     204     
     205  echo"<tr><td colspan='3'><h3>Email Format Options</h3></td></tr>"; 
     206$savedEmailPostLinkVal = get_option('draftnotifyemailpostlink');
     207$savedEmailAuthorNameVal = get_option('draftnotifyemailauthorname');
     208$savedEmailAuthorEmailAddressVal = get_option('draftnotifyemailauthoremail');
     209
     210$checked = ($savedEmailPostLinkVal)?" checked='checked' ":"";
     211echo"<tr>
     212<td valign='top'><b>Include Link to Posts in Email:</b></td>
     213<td valign='top'><input id='draftnotifyemailpostlink' name='draftnotifyemailpostlink' type='checkbox' {$checked}> Check to send</td>
     214<td valign='top'>&nbsp;</td>
     215</tr>";
     216
     217$checked = ($savedEmailAuthorNameVal)?" checked='checked' ":"";
     218echo"<tr>
     219<td valign='top'><b>Include Author's Real Name in Email:</b></td>
     220<td valign='top'><input id='draftnotifyemailauthorname' name='draftnotifyemailauthorname' type='checkbox' {$checked}> Check to send</td>
     221<td valign='top'>&nbsp;</td>
     222</tr>";
     223
     224$checked = ($savedEmailAuthorEmailAddressVal)?" checked='checked' ":"";
     225echo"<tr>
     226<td valign='top'><b>Include Author's Email Address in Email:</b></td>
     227<td valign='top'><input id='draftnotifyemailauthoremail' name='draftnotifyemailauthoremail' type='checkbox' {$checked}> Check to send</td>
     228<td valign='top'>&nbsp;</td>
     229</tr>";
     230
     231echo "</table>";
    172232
    173233 submit_button();
  • draft-notify/trunk/readme.txt

    r677289 r680651  
    1313== Description ==
    1414
    15 I run multiple blogs and have the ability for people to sign up and write content for me. I was disappointed that WordPress does not have anything built it to alert me with an email notification when a new author writes something. I don’t log into the sites unless I have to, so new content may sit for a while without being noticed. I did find 1 plugin that would accomplish the email, but it was buggy. So I’ve written my own and am willing to share it with you. Specifically this plugin is designed to email you when an author saves a draft. Now there are some additional settings, but check them out below. As always, suggestions are welcome, just leave them in the comments along with any bugs you might encounter.
     15I run multiple blogs and have the ability for people to sign up and write content for me. I was disappointed that WordPress does not have anything built it to alert me with an email notification when a new author writes something. I don�t log into the sites unless I have to, so new content may sit for a while without being noticed. I did find 1 plugin that would accomplish the email, but it was buggy. So I�ve written my own and am willing to share it with you. Specifically this plugin is designed to email you when an author saves a draft. Now there are some additional settings, but check them out below. As always, suggestions are welcome, just leave them in the comments along with any bugs you might encounter.
    1616
    1717= Draft Notify Features =
     
    3838
    3939== Changelog ==
     40= 1.2 =
     41* Added a few options into the settings page that customize the email you receive.
    4042
    4143= 1.1 =
Note: See TracChangeset for help on using the changeset viewer.