PluginProbe
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity / 1.6.0
Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity v1.6.0
3.3.9 3.3.8 trunk 1.0 1.1.0 1.10.0 1.11.0 1.11.1 1.12.0 1.13.0 1.14.0 1.15.0 1.16.0 1.17.0 1.17.1 1.18.0 1.19.0 1.2.0 1.20.0 1.20.1 1.3.0 1.3.1 1.4.0 1.5.0 1.6.0 All 67 releases
logtivity / Logs / Core / Logtivity_Comment.php

Logtivity_Comment.php in Activity Logs, User Activity Tracking, Multisite Activity Log from Logtivity 1.6.0, at Logs/Core/Logtivity_Comment.php

42 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class Logtivity_Comment
4 {
5 public function __construct()
6 {
7 add_action('comment_post', [$this, 'commentCreated'], 10, 3);
8 add_action( 'wp_set_comment_status', [$this, 'statusChanged'], 10, 2);
9 add_action( 'unspam_comment', [$this, 'commentMarkedAsNotspam'], 10, 2);
10 }
11
12 public function commentCreated($comment_ID, $comment_approved, $commentdata)
13 {
14 return Logtivity_Logger::log()
15 ->setAction('Comment Created')
16 ->setContext(substr(strip_tags($commentdata['comment_content']), 0, 30).'...')
17 ->addMeta('Author', $commentdata['comment_author'] ?? null)
18 ->addMeta('Approved', $comment_approved)
19 ->addMeta('Post URL', get_permalink($commentdata['comment_post_ID']))
20 ->send();
21 }
22
23 public function statusChanged($comment_id, $comment_status)
24 {
25 if (in_array($comment_status, ['0', '1'])) {
26 return;
27 }
28
29 return Logtivity_Logger::log()
30 ->setAction('Comment Status Changed')
31 ->setContext($comment_status)
32 ->addMeta('Comment ID', $comment_id)
33 ->send();
34 }
35
36 public function commentMarkedAsNotspam($comment_ID, $comment)
37 {
38 return $this->statusChanged($comment->comment_ID, 'Not Spam');
39 }
40 }
41
42 $Logtivity_Comment = new Logtivity_Comment;