$action, 'object_type' => 'Comments', 'object_subtype' => get_post_type( $comment->comment_post_ID ), 'object_name' => esc_html( get_the_title( $comment->comment_post_ID ) ), 'object_id' => $id, ] ); } public function handle_comment_log( $comment_ID, $comment = null ) { if ( is_null( $comment ) ) { $comment = get_comment( $comment_ID ); } $action = 'created'; switch ( current_filter() ) { case 'wp_insert_comment': $action = 1 === (int) $comment->comment_approved ? 'approved' : 'pending'; break; case 'edit_comment': $action = 'updated'; break; case 'delete_comment': $action = 'deleted'; break; case 'trash_comment': $action = 'trashed'; break; case 'untrash_comment': $action = 'untrashed'; break; case 'spam_comment': $action = 'spammed'; break; case 'unspam_comment': $action = 'unspammed'; break; } $this->_add_comment_log( $comment_ID, $action, $comment ); } public function hooks_transition_comment_status( $new_status, $old_status, $comment ) { $this->_add_comment_log( $comment->comment_ID, $new_status, $comment ); } }