CommentCount.php
957 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace AC\Column\Post;
use AC\Column;
use AC\Settings;
/**
* Column displaying the number of comments for an item, displaying either the total
* amount of comments, or the amount per status (e.g. "Approved", "Pending").
* @since 2.0
*/
class CommentCount extends Column {
public function __construct() {
$this->set_type( 'column-comment_count' );
$this->set_label( __( 'Comment Count', 'codepress-admin-columns' ) );
}
public function get_value( $id ) {
return $this->get_formatted_value( $id );
}
public function is_valid() {
return post_type_supports( $this->get_post_type(), 'comments' );
}
public function register_settings() {
$this->add_setting( new Settings\Column\CommentCount( $this ) );
}
public function get_setting_comment_count(): ?Settings\Column\CommentCount {
$setting = $this->get_setting( 'comment_count' );
return $setting instanceof Settings\Column\CommentCount
? $setting
: null;
}
}