/** * When a comment is approved notify subscribers if needed. * * @param string $new_status * @param string $old_status * @param object $comment */ public static function action_transition_comment_status($new_status, $old_status, $comment) { if (!Prompt_Core::$options->get('enable_comment_delivery')) { return; } if (defined('WP_IMPORTING') and WP_IMPORTING) { return; } if ('approved' != $new_status or $old_status == $new_status or !empty($comment->comment_type)) { return; } Prompt_Comment_Mailing::send_notifications($comment); }
/** * Add a comment based on the message text. * @since 1.0.0 */ protected function add_comment() { $text = $this->get_message_text(); $post = get_post($this->post_id); if (!$post or 'publish' != $post->post_status or !comments_open($this->post_id)) { trigger_error(sprintf(__('rejected comment on unqualified post %s', 'Postmatic'), $this->post_id), E_USER_NOTICE); Prompt_Comment_Mailing::send_rejected_notification($this->user_id, $this->post_id); return; } if ($this->comment_exists($text)) { trigger_error(sprintf(__('rejected duplicate comment on %s', 'Postmatic'), $this->post_id), E_USER_NOTICE); return; } $this->subscribe($notify = false); $user = get_userdata($this->user_id); $comment_data = array('user_id' => $this->user_id, 'comment_post_ID' => $this->post_id, 'comment_content' => $text, 'comment_agent' => __CLASS__, 'comment_author' => $user->display_name, 'comment_author_IP' => '', 'comment_author_url' => $user->user_url, 'comment_author_email' => $user->user_email, 'comment_parent' => $this->parent_comment_id, 'comment_type' => '', 'comment_date_gmt' => current_time('mysql', 1)); remove_all_actions('check_comment_flood'); $comment_data = wp_filter_comment($comment_data); $comment_data['comment_approved'] = $this->approve_comment($comment_data); $comment_id = wp_insert_comment($comment_data); if (0 == $comment_data['comment_approved']) { wp_notify_moderator($comment_id); } }