PluginProbe ʕ •ᴥ•ʔ
Admin Columns / 3.0.5
Admin Columns v3.0.5
7.1.4 7.0.19 2.3.5 2.4 2.4.1 2.4.10 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.6.1 2.5.6.2 2.5.6.3 2.5.6.4 3.0 3.0.1 3.0.2 3.0.3 3.0.5 3.0.7 3.1 3.1.1 3.1.10 3.1.2 3.1.3 3.1.5 3.2.3 3.2.7 3.3.1 3.4.1 3.4.6 3.4.8 4.0.1 4.0.3 4.1.6 4.2.2 4.2.5 4.3 4.3.2 4.4.1 4.4.4 4.4.5 4.5.5 4.6.1 4.7.18 4.7.19 4.7.20 4.7.7 7.0.13 7.0.14 7.0.16 trunk 1.0 1.1 1.1.3 1.2 1.2.1 1.3 1.3.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.5.1 1.4.6 1.4.6.1 1.4.6.2 1.4.6.3 1.4.6.4 1.4.7 1.4.8 1.4.9 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2 2.2.1 2.2.1.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.5.1 2.2.6 2.2.6.1 2.2.6.2 2.2.6.3 2.2.6.4 2.2.7 2.2.8 2.2.8.1 2.2.9 2.3.1 2.3.2 2.3.3
codepress-admin-columns / classes / Settings / Column / CommentCount.php
codepress-admin-columns / classes / Settings / Column Last commit date
BeforeAfter 8 years ago ActionIcons.php 8 years ago AttachmentDisplay.php 8 years ago BeforeAfter.php 8 years ago CharacterLimit.php 8 years ago CommentCount.php 8 years ago CustomField.php 8 years ago CustomFieldType.php 8 years ago Date.php 8 years ago ExifData.php 8 years ago Image.php 8 years ago Images.php 8 years ago Label.php 8 years ago LinkLabel.php 8 years ago LinkToMenu.php 8 years ago Message.php 8 years ago Meta.php 8 years ago MissingImageSize.php 8 years ago NumberOfItems.php 8 years ago Password.php 8 years ago PathScope.php 8 years ago Post.php 8 years ago PostFormatIcon.php 8 years ago PostLink.php 8 years ago PostType.php 8 years ago Separator.php 8 years ago StatusIcon.php 8 years ago StringLimit.php 8 years ago Taxonomy.php 8 years ago Term.php 8 years ago Toggle.php 8 years ago Type.php 8 years ago User.php 8 years ago Width.php 8 years ago WordLimit.php 8 years ago WordsPerMinute.php 8 years ago
CommentCount.php
111 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 class AC_Settings_Column_CommentCount extends AC_Settings_Column
8 implements AC_Settings_FormatValueInterface {
9
10 /**
11 * @var string
12 */
13 private $comment_status;
14
15 public function get_name() {
16 return 'comment_count';
17 }
18
19 protected function define_options() {
20 return array(
21 'comment_status' => 'total_comments',
22 );
23 }
24
25 /**
26 * @return AC_View
27 */
28 public function create_view() {
29 $setting = $this->create_element( 'select' )
30 ->set_options( $this->get_comment_statuses() );
31
32 $view = new AC_View( array(
33 'label' => __( 'Comment status', 'codepress-admin-columns' ),
34 'tooltip' => __( 'Select which comment status you like to display.', 'codepress-admin-columns' ),
35 'setting' => $setting,
36 ) );
37
38 return $view;
39 }
40
41 /**
42 * @return array
43 */
44 protected function get_comment_statuses() {
45 $options = array(
46 'approved' => __( 'Approved', 'codepress-admin-columns' ),
47 'moderated' => __( 'Pending', 'codepress-admin-columns' ),
48 'spam' => __( 'Spam', 'codepress-admin-columns' ),
49 'trash' => __( 'Trash', 'codepress-admin-columns' ),
50 );
51
52 natcasesort( $options );
53
54 // First
55 $options = array( 'total_comments' => __( 'Total', 'codepress-admin-columns' ) ) + $options;
56
57 return $options;
58 }
59
60 /**
61 * @return int
62 */
63 public function get_comment_status() {
64 return $this->comment_status;
65 }
66
67 /**
68 * @param string $comment_status
69 *
70 * @return bool
71 */
72 public function set_comment_status( $comment_status ) {
73 $this->comment_status = $comment_status;
74
75 return true;
76 }
77
78 /**
79 * @param int $post_id
80 *
81 * @return int
82 */
83 public function get_comment_count( $post_id ) {
84 $status = $this->get_comment_status();
85 $count = wp_count_comments( $post_id );
86
87 if ( empty( $count->$status ) ) {
88 return false;
89 }
90
91 return $count->$status;
92 }
93
94 /**
95 * @param int $post_id
96 * @param int $original_value
97 *
98 * @return false|string
99 */
100 public function format( $post_id, $original_value ) {
101 $count = $this->get_comment_count( $post_id );
102
103 if ( ! $count ) {
104 return $this->column->get_empty_char();
105 }
106
107 return ac_helper()->html->link( add_query_arg( array( 'p' => $post_id, 'comment_status' => $this->get_comment_status() ), admin_url( 'edit-comments.php' ) ), $count );
108 }
109
110 }
111