Пример #1
0
 public function new_comment($comment, $post_type, $question_id)
 {
     $emails = ap_get_email_to_notify($comment->comment_post_ID, $comment->user_id);
     $post = get_post($question_id);
     if ($post_type == 'question') {
         $subject = __('New comment on: ', 'ap') . $post->post_title;
         $message = sprintf(__('Hello!,<br /><br /> A new comment is posted by %s <br />', 'ap'), ap_user_display_name($comment->user_id, true));
         $message .= ap_truncate_chars($comment->comment_content, 100);
         $message .= "<br /><br /><a href='" . get_comments_link($parent->ID) . "'>" . __('View comment', 'ap') . "</a><br />";
         $message .= '<p style="color:#777; font-size:11px">' . __('Powered by', 'ap') . '<a href="http://open-wp.com">AnsPress</a></p>';
         if (!empty($emails)) {
             foreach ($emails as $email) {
                 wp_mail($email, $subject, $message);
             }
         }
     } else {
         $subject = __('New comment on answer of: ', 'ap') . $post->post_title;
         $message = sprintf(__('Hello!,<br /><br /> A new comment is posted by %s <br />', 'ap'), ap_user_display_name($comment->user_id, true));
         $message .= ap_truncate_chars($comment->comment_content, 100);
         $message .= "<br /><br /><a href='" . get_comments_link($parent->ID) . "'>" . __('View comment', 'ap') . "</a><br />";
         $message .= '<p style="color:#777; font-size:11px">' . __('Powered by', 'ap') . '<a href="http://open-wp.com">AnsPress</a></p>';
         if (!empty($emails)) {
             foreach ($emails as $email) {
                 wp_mail($email, $subject, $message);
             }
         }
     }
 }
Пример #2
0
 public function select_answer($user_id, $question_id, $answer_id)
 {
     $post_url = get_permalink($question_id);
     $post = get_post($post_id);
     $subject = __('Your answer is selected as a best', 'ap');
     $message = sprintf(__('Hello!, <br /><br /> You answer on %s is selected as best by %s <br />', 'ap'), $pos->post_title, ap_user_display_name($user_id, true));
     $message .= "<br /><br /><a href='" . $post_url . "'>" . __('View question', 'ap') . "</a><br />";
     $message .= '<p style="color:#777; font-size:11px">' . __('Powered by', 'ap') . ' <a href="http://open-wp.com">AnsPress</a></p>';
     $emails = ap_get_email_to_notify($post->post_parent, $user_id);
     if (!empty($emails)) {
         foreach ($emails as $email) {
             wp_mail($email, $subject, $message);
         }
     }
     //sends email
     wp_mail(get_option('admin_email'), $subject, $message);
 }