public static function callback_wp_insert_comment($comment_id, $comment) { if (in_array($comment->comment_type, self::get_ignored_comment_types())) { return; } $user_id = self::get_comment_author($comment, 'id'); $user_name = self::get_comment_author($comment, 'name'); $post_id = $comment->comment_post_ID; $post_type = get_post_type($post_id); $post_title = ($post = get_post($post_id)) ? "\"{$post->post_title}\"" : __('a post', 'mainwp-child-reports'); $comment_status = 1 == $comment->comment_approved ? __('approved automatically', 'mainwp-child-reports') : __('pending approval', 'mainwp-child-reports'); $is_spam = false; // Auto-marked spam comments if (class_exists('Akismet') && Akismet::matches_last_comment($comment)) { $ak_last_comment = Akismet::get_last_comment(); if ('true' == $ak_last_comment['akismet_result']) { $is_spam = true; $comment_status = __('automatically marked as spam by Akismet', 'mainwp-child-reports'); } } $comment_type = mb_strtolower(self::get_comment_type_label($comment_id)); if ($comment->comment_parent) { $parent_user_id = get_comment_author($comment->comment_parent, 'id'); $parent_user_name = get_comment_author($comment->comment_parent, 'name'); self::log(_x('Reply to %1$s\'s %5$s by %2$s on %3$s %4$s', "1: Parent comment's author, 2: Comment author, 3: Post title, 4: Comment status, 5: Comment type", 'mainwp_child_reports'), compact('parent_user_name', 'user_name', 'post_title', 'comment_status', 'comment_type', 'post_id', 'parent_user_id'), $comment_id, array($post_type => 'replied'), $user_id); } else { self::log(_x('New %4$s by %1$s on %2$s %3$s', '1: Comment author, 2: Post title 3: Comment status, 4: Comment type', 'mainwp_child_reports'), compact('user_name', 'post_title', 'comment_status', 'comment_type', 'post_id', 'is_spam'), $comment_id, array($post_type => $is_spam ? 'spammed' : 'created'), $user_id); } }
/** * Tracks comment creation * * @action wp_insert_comment * * @param int $comment_id * @param object $comment */ public function callback_wp_insert_comment($comment_id, $comment) { if (in_array($comment->comment_type, $this->get_ignored_comment_types())) { return; } $user_id = $this->get_comment_author($comment, 'id'); $user_name = $this->get_comment_author($comment, 'name'); $post_id = $comment->comment_post_ID; $post_type = get_post_type($post_id); $post_title = ($post = get_post($post_id)) ? "\"{$post->post_title}\"" : esc_html__('a post', 'stream'); $comment_status = 1 === $comment->comment_approved ? esc_html__('approved automatically', 'stream') : esc_html__('pending approval', 'stream'); $is_spam = false; // Auto-marked spam comments $options = wp_stream_get_instance()->settings->options; $ak_tracking = isset($options['advanced_akismet_tracking']) ? $options['advanced_akismet_tracking'] : false; if (class_exists('Akismet') && $ak_tracking && \Akismet::matches_last_comment($comment)) { $ak_last_comment = \Akismet::get_last_comment(); if ('true' === $ak_last_comment['akismet_result']) { $is_spam = true; $comment_status = esc_html__('automatically marked as spam by Akismet', 'stream'); } } $comment_type = mb_strtolower($this->get_comment_type_label($comment_id)); if ($comment->comment_parent) { $parent_user_id = get_comment_author($comment->comment_parent, 'id'); $parent_user_name = get_comment_author($comment->comment_parent, 'name'); $this->log(_x('Reply to %1$s\'s %5$s by %2$s on %3$s %4$s', "1: Parent comment's author, 2: Comment author, 3: Post title, 4: Comment status, 5: Comment type", 'stream'), compact('parent_user_name', 'user_name', 'post_title', 'comment_status', 'comment_type', 'post_id', 'parent_user_id'), $comment_id, $post_type, 'replied', $user_id); } else { $this->log(_x('New %4$s by %1$s on %2$s %3$s', '1: Comment author, 2: Post title 3: Comment status, 4: Comment type', 'stream'), compact('user_name', 'post_title', 'comment_status', 'comment_type', 'post_id', 'is_spam'), $comment_id, $post_type, $is_spam ? 'spammed' : 'created', $user_id); } }