Advertisement
Guest User

blogname_as_sender.patch

a guest
Dec 29th, 2010
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 6.46 KB | None | 0 0
  1. diff -r bd41eef81acb -r 32e4f0d0ab0c subscribe2.php
  2. --- a/subscribe2.php    Wed Dec 22 14:47:56 2010 +0100
  3. +++ b/subscribe2.php    Wed Dec 22 14:49:20 2010 +0100
  4. @@ -418,19 +418,24 @@ class s2class {
  5.         return $status;
  6.     } // end mail()
  7.  
  8.     /**
  9.     Construct standard set of email headers
  10.     */
  11.     function headers($type='text') {
  12.         if ( empty($this->myname) || empty($this->myemail) ) {
  13. -           $admin = $this->get_userdata($this->subscribe2_options['sender']);
  14. -           $this->myname = html_entity_decode($admin->display_name, ENT_QUOTES);
  15. -           $this->myemail = $admin->user_email;
  16. +           if ( $this->subscribe2_options['sender'] == 'blogname' ) {
  17. +               $this->myname = html_entity_decode(get_bloginfo('name'), ENT_QUOTES);
  18. +               $this->myemail = get_bloginfo('admin_email');
  19. +           } else {
  20. +               $admin = $this->get_userdata($this->subscribe2_options['sender']);
  21. +               $this->myname = html_entity_decode($admin->display_name, ENT_QUOTES);
  22. +               $this->myemail = $admin->user_email;
  23. +           }
  24.         }
  25.  
  26.         $header['From'] = $this->myname . " <" . $this->myemail . ">";
  27.         $header['Reply-To'] = $this->myname . " <" . $this->myemail . ">";
  28.         $header['Return-path'] = "<" . $this->myemail . ">";
  29.         $header['Precedence'] = "list\nList-Id: " . get_option('blogname') . "";
  30.         $header['X-Mailer'] = "PHP" . phpversion() . "";
  31.         if ( $type == 'html' ) {
  32. @@ -541,27 +546,31 @@ class s2class {
  33.         // passing them in function calls a little later
  34.         $this->post_title = "<a href=\"" . get_permalink($post->ID) . "\">" . html_entity_decode($post->post_title, ENT_QUOTES) . "</a>";
  35.         $this->permalink = get_permalink($post->ID);
  36.         $this->post_date = get_the_time(get_option('date_format'));
  37.         $this->post_time = get_the_time();
  38.  
  39.         $author = get_userdata($post->post_author);
  40.         $this->authorname = $author->display_name;
  41. -
  42.         // do we send as admin, or post author?
  43.         if ( 'author' == $this->subscribe2_options['sender'] ) {
  44.             // get author details
  45.             $user = &$author;
  46. +           $this->myemail = $user->user_email;
  47. +           $this->myname = html_entity_decode($user->display_name, ENT_QUOTES);
  48. +       } elseif ( 'blogname' == $this->subscribe2_options['sender'] ) {
  49. +           $this->myemail = get_bloginfo('admin_email');
  50. +           $this->myname = html_entity_decode(get_bloginfo('name'), ENT_QUOTES);
  51.         } else {
  52.             // get admin details
  53.             $user = $this->get_userdata($this->subscribe2_options['sender']);
  54. +           $this->myemail = $user->user_email;
  55. +           $this->myname = html_entity_decode($user->display_name, ENT_QUOTES);
  56.         }
  57. -       $this->myemail = $user->user_email;
  58. -       $this->myname = html_entity_decode($user->display_name, ENT_QUOTES);
  59.  
  60.         $this->post_cat_names = implode(', ', wp_get_post_categories($post->ID, array('fields' => 'names')));
  61.         $this->post_tag_names = implode(', ', wp_get_post_tags($post->ID, array('fields' => 'names')));
  62.  
  63.         // Get email subject
  64.         $subject = stripslashes(strip_tags($this->substitute($this->subscribe2_options['notification_subject'])));
  65.         // Get the message template
  66.         $mailtext = apply_filters('s2_email_template', $this->subscribe2_options['mailtext']);
  67. @@ -1861,19 +1870,22 @@ class s2class {
  68.                 // BCClimit
  69.                 if ( is_numeric($_POST['bcc']) && $_POST['bcc'] >= 0 ) {
  70.                     $this->subscribe2_options['bcclimit'] = $_POST['bcc'];
  71.                 }
  72.                 // admin_email
  73.                 $this->subscribe2_options['admin_email'] = $_POST['admin_email'];
  74.  
  75.                 // send as author or admin?
  76. -               $sender = 'author';
  77.                 if ( is_numeric($_POST['sender']) ) {
  78.                     $sender = $_POST['sender'];
  79. +               } elseif ($_POST['sender'] == 'author') {
  80. +                   $sender = 'author';            
  81. +               } else {
  82. +                   $sender = 'blogname';
  83.                 }
  84.                 $this->subscribe2_options['sender'] = $sender;
  85.  
  86.                 // send email for pages, private and password protected posts
  87.                 $this->subscribe2_options['stylesheet'] = $_POST['stylesheet'];
  88.                 $this->subscribe2_options['pages'] = $_POST['pages'];
  89.                 $this->subscribe2_options['password'] = $_POST['password'];
  90.                 $this->subscribe2_options['private'] = $_POST['private'];
  91. @@ -2809,19 +2821,19 @@ class s2class {
  92.             $wp_user_search = new WP_User_Search( '', '', $role);
  93.             $admins_string = implode(', ', $wp_user_search->get_results());
  94.             $sql = "SELECT ID, display_name FROM $wpdb->users WHERE ID IN (" . $admins_string . ")";
  95.             $admins = $wpdb->get_results($sql);
  96.         }
  97.  
  98.         if ( $inc_author ) {
  99.             $author[] = (object)array('ID' => 'author', 'display_name' => 'Post Author');
  100. +           $author[] = (object)array('ID' => 'blogname', 'display_name' => html_entity_decode(get_bloginfo('name'), ENT_QUOTES));
  101.             $admins = array_merge($author, $admins);
  102.         }
  103. -
  104.         echo "<select name=\"sender\">\r\n";
  105.         foreach ( $admins as $admin ) {
  106.             echo "<option value=\"" . $admin->ID . "\"";
  107.             if ( $admin->ID == $this->subscribe2_options['sender'] ) {
  108.                 echo " selected=\"selected\"";
  109.             }
  110.             echo ">" . $admin->display_name . "</option>\r\n";
  111.         }
  112. @@ -3534,20 +3546,24 @@ class s2class {
  113.         $message_posttime = trim($message_posttime);
  114.  
  115.         //sanity check - don't send a mail if the content is empty
  116.         if ( !$message_post && !$message_posttime && !$table && !$tablelinks ) {
  117.             return;
  118.         }
  119.  
  120.         // get admin details
  121. -       $user = $this->get_userdata($this->subscribe2_options['sender']);
  122. -       $this->myemail = $user->user_email;
  123. -       $this->myname = html_entity_decode($user->display_name, ENT_QUOTES);
  124. -
  125. +       if ( $this->subscribe2_options['sender'] == 'blogname' ) {
  126. +           $this->myname = html_entity_decode(get_bloginfo('name'), ENT_QUOTES);
  127. +           $this->myemail = get_bloginfo('admin_email');
  128. +       } else {
  129. +           $user = $this->get_userdata($this->subscribe2_options['sender']);
  130. +           $this->myemail = $user->user_email;
  131. +           $this->myname = html_entity_decode($user->display_name, ENT_QUOTES);
  132. +       }
  133.         $scheds = (array)wp_get_schedules();
  134.         $email_freq = $this->subscribe2_options['email_freq'];
  135.         $display = $scheds[$email_freq]['display'];
  136.         ( '' == get_option('blogname') ) ? $subject = "" : $subject = "[" . stripslashes(get_option('blogname')) . "] ";
  137.         $subject .= $display . " " . __('Digest Email', 'subscribe2');
  138.         $mailtext = str_replace("TABLELINKS", $tablelinks, $mailtext);
  139.         $mailtext = str_replace("TABLE", $table, $mailtext);
  140.         $mailtext = str_replace("POSTTIME", $message_posttime, $mailtext);
  141. @@ -3730,9 +3746,9 @@ class s2class {
  142.     var $added = '';
  143.     var $deleted = '';
  144.     var $subscribe = '';
  145.     var $unsubscribe = '';
  146.     var $confirm_subject = '';
  147.     var $options_saved = '';
  148.     var $options_reset = '';
  149.  } // end class subscribe2
  150. -?>
  151. \ No newline at end of file
  152. +?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement