HasReplies.php
751 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
41
<?php
namespace ACP\Column\Comment;
use AC;
use ACP\Search;
class HasReplies extends AC\Column
implements Search\Searchable {
public function __construct() {
$this->set_type( 'column-has_replies' );
$this->set_label( __( 'Has Replies', 'codepress-admin-columns' ) );
}
public function get_value( $id ) {
$comments = $this->get_raw_value( $id );
return $comments ? ac_helper()->icon->yes() : ac_helper()->icon->no();
}
/**
* @param int $id
*
* @return int
*/
public function get_raw_value( $id ) {
global $wpdb;
return (int) $wpdb->get_var( "
SELECT count(*)
FROM {$wpdb->comments}
WHERE comment_parent = {$id}
" );
}
public function search() {
return new Search\Comparison\Comment\HasReplies();
}
}