CommentCount.php
4 years ago
Description.php
4 years ago
DisplayName.php
4 years ago
Email.php
4 years ago
FirstName.php
4 years ago
FirstPost.php
4 years ago
FullName.php
4 years ago
ID.php
4 years ago
LastName.php
4 years ago
LastPost.php
4 years ago
Login.php
4 years ago
Name.php
4 years ago
Nicename.php
4 years ago
Nickname.php
4 years ago
PostCount.php
4 years ago
Posts.php
4 years ago
Registered.php
4 years ago
RichEditing.php
4 years ago
Role.php
4 years ago
ShowToolbar.php
4 years ago
Url.php
4 years ago
Username.php
4 years ago
CommentCount.php
35 lines
| 1 | <?php |
| 2 | |
| 3 | namespace AC\Column\User; |
| 4 | |
| 5 | use AC\Column; |
| 6 | |
| 7 | /** |
| 8 | * @since 2.0 |
| 9 | */ |
| 10 | class CommentCount extends Column { |
| 11 | |
| 12 | public function __construct() { |
| 13 | $this->set_type( 'column-user_commentcount' ) |
| 14 | ->set_label( __( 'Comments', 'codepress-admin-columns' ) ); |
| 15 | } |
| 16 | |
| 17 | public function get_raw_value( $user_id ) { |
| 18 | return get_comments( [ |
| 19 | 'user_id' => $user_id, |
| 20 | 'count' => true, |
| 21 | 'orderby' => false, |
| 22 | ] ); |
| 23 | } |
| 24 | |
| 25 | public function get_value( $user_id ) { |
| 26 | $count = $this->get_raw_value( $user_id ); |
| 27 | |
| 28 | if ( ! $count ) { |
| 29 | return $this->get_empty_char(); |
| 30 | } |
| 31 | |
| 32 | return sprintf( '<a href="%s">%s</a>', add_query_arg( [ 'user_id' => $user_id ], admin_url( 'edit-comments.php' ) ), $count ); |
| 33 | } |
| 34 | |
| 35 | } |