Skip to content

Commit 7867065

Browse files
committed
WPCOM Comments: Only show like actions on edit-comments
1 parent f61c81a commit 7867065

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

projects/packages/jetpack-mu-wpcom/src/features/wpcom-comments/wpcom-comments.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ private function __construct() {
3939
add_action( 'rest_api_init', array( $this, 'register_like_api' ) );
4040
}
4141

42-
add_action( 'admin_init', array( $this, 'init' ) );
42+
add_action( 'current_screen', array( $this, 'init' ) );
4343
}
4444

4545
/**
@@ -63,11 +63,18 @@ public function init() {
6363
return;
6464
}
6565

66-
if ( is_admin() ) {
67-
add_filter( 'comment_class', array( $this, 'add_like_class' ), 10, 3 );
68-
add_filter( 'comment_row_actions', array( $this, 'enable_likes' ), 10, 2 );
69-
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 10, 2 );
66+
if ( ! is_admin() ) {
67+
return;
7068
}
69+
70+
$screen = get_current_screen();
71+
if ( ! $screen || 'edit-comments' !== $screen->id ) {
72+
return;
73+
}
74+
75+
add_filter( 'comment_class', array( $this, 'add_like_class' ), 10, 3 );
76+
add_filter( 'comment_row_actions', array( $this, 'enable_likes' ), 10, 2 );
77+
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 10, 2 );
7178
}
7279

7380
/**

0 commit comments

Comments
 (0)