| @@ -15,17 +15,20 @@ | ||
| 15 | 15 | * |
| 16 | 16 | * @return void |
| 17 | 17 | */ |
| 18 | 18 | public function __construct() { |
| 19 | - add_action( 'wp_insert_comment', array( &$this, 'handleCommentLog' ), 10, 2 ); | |
| 20 | - add_action( 'edit_comment', array( &$this, 'handleCommentLog' ) ); | |
| 21 | - add_action( 'trash_comment', array( &$this, 'handleCommentLog' ) ); | |
| 22 | - add_action( 'untrash_comment', array( &$this, 'handleCommentLog' ) ); | |
| 23 | - add_action( 'spam_comment', array( &$this, 'handleCommentLog' ) ); | |
| 24 | - add_action( 'unspam_comment', array( &$this, 'handleCommentLog' ) ); | |
| 25 | - add_action( 'delete_comment', array( &$this, 'handleCommentLog' ) ); | |
| 26 | - add_action( 'transition_comment_status', array( &$this, 'transitionCommentStatus' ), 10, 3 ); | |
| 19 | + if ( ! get_option( 'patchstack_activity_log_comments', 0 ) ) { | |
| 20 | + return; | |
| 21 | + } | |
| 27 | 22 | |
| 23 | + add_action( 'wp_insert_comment', [ &$this, 'handleCommentLog' ], 10, 2 ); | |
| 24 | + add_action( 'edit_comment', [ &$this, 'handleCommentLog' ] ); | |
| 25 | + add_action( 'trash_comment', [ &$this, 'handleCommentLog' ] ); | |
| 26 | + add_action( 'untrash_comment', [ &$this, 'handleCommentLog' ] ); | |
| 27 | + add_action( 'spam_comment', [ &$this, 'handleCommentLog' ] ); | |
| 28 | + add_action( 'unspam_comment', [ &$this, 'handleCommentLog' ] ); | |
| 29 | + add_action( 'delete_comment', [ &$this, 'handleCommentLog' ] ); | |
| 30 | + add_action( 'transition_comment_status', [ &$this, 'transitionCommentStatus' ], 10, 3 ); | |
| 28 | 31 | } |
| 29 | 32 | |
| 30 | 33 | /** |
| 31 | 34 | * Log the action regarding the comment. |
| @@ -40,14 +43,14 @@ | ||
| 40 | 43 | $comment = get_comment( $id ); |
| 41 | 44 | } |
| 42 | 45 | |
| 43 | 46 | $this->insert( |
| 44 | - array( | |
| 47 | + [ | |
| 45 | 48 | 'action' => $action, |
| 46 | 49 | 'object' => 'comment', |
| 47 | 50 | 'object_id' => $id, |
| 48 | 51 | 'object_name' => esc_html( get_the_title( $comment->comment_post_ID ) ), |
| 49 | - ) | |
| 52 | + ] | |
| 50 | 53 | ); |
| 51 | 54 | } |
| 52 | 55 | |
| 53 | 56 | /** |