public function ap_after_update_answer($answer_id) { if (!ap_opt('notify_admin_edit_answer')) { return; } $current_user = wp_get_current_user(); $answer = get_post($answer_id); $this->emails = array(); if (ap_opt('notify_admin_email') != $current_user->user_email && ap_opt('notify_admin_edit_answer')) { $this->emails[] = ap_opt('notify_admin_email'); } $subscribers = ap_get_subscribers($answer_id, 'a_all', 100, true); $post_author = get_user_by('id', $answer->post_author); if (!ap_in_array_r($post_author->data->user_email, $subscribers)) { $subscribers[] = (object) array('user_email' => $post_author->data->user_email, 'ID' => $post_author->ID, 'display_name' => $post_author->data->display_name); } if ($subscribers) { foreach ($subscribers as $s) { if (!empty($s->user_email) && $s->user_email != $current_user->user_email) { $this->emails[] = $s->user_email; } } } if (!is_array($this->emails) || empty($this->emails)) { return; } $args = array('{answerer}' => ap_user_display_name($answer->post_author), '{editor}' => ap_user_display_name(get_current_user_id()), '{question_title}' => $answer->post_title, '{question_link}' => get_permalink($answer->post_parent), '{answer_content}' => $answer->post_content); $args = apply_filters('ap_edit_answer_email_tags', $args); $this->subject = $this->replace_tags(ap_opt('edit_answer_email_subject'), $args); $this->message = $this->replace_tags(ap_opt('edit_answer_email_body'), $args); $this->initiate_send_email(); }
/** * Notify admin on new comment and is not approved * @param object $comment Comment id */ public function new_comment($comment) { $current_user = wp_get_current_user(); $post = get_post($comment->comment_post_ID); $post_id = $post->ID; $args = array('{commenter}' => ap_user_display_name($comment->user_id), '{question_title}' => $post->post_title, '{comment_link}' => get_comment_link($comment), '{comment_content}' => $comment->comment_content); $args = apply_filters('ap_new_comment_email_tags', $args); $this->subject = $this->replace_tags(ap_opt('new_comment_email_subject'), $args); $this->message = $this->replace_tags(ap_opt('new_comment_email_body'), $args); $this->emails = array(); $subscribers = ap_get_comments_subscribers_data($post_id); $post_author = get_user_by('id', $post->post_author); if (!ap_in_array_r($post_author->data->user_email, $subscribers)) { $subscribers[] = (object) array('user_email' => $post_author->data->user_email, 'ID' => $post_author->ID, 'display_name' => $post_author->data->display_name); } if ($subscribers) { foreach ($subscribers as $s) { if ($s->user_email != $current_user->user_email) { $this->emails[] = $s->user_email; } } } $this->initiate_send_email(); }