bbp_dashboard_widget_right_now()

Forums Dashboard Right Now Widget

Description

Adds a dashboard widget with forum statistics

Source

File: bp-forums/admin/metaboxes.php

33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
function bbp_dashboard_widget_right_now() {
 
    // Get the statistics
    $r = bbp_get_statistics(); ?>
 
    <div class="table table_content">
 
        <p class="sub"><?php esc_html_e( 'Forum Discussions', 'buddyboss' ); ?></p>
 
        <table>
 
            <tr class="first">
 
                <?php
                    $num  = $r['forum_count'];
                    $text = _n( 'Forum', 'Forums', $r['forum_count'], 'buddyboss' );
                    if ( current_user_can( 'publish_forums' ) ) {
                        $link = add_query_arg( array( 'post_type' => bbp_get_forum_post_type() ), get_admin_url( null, 'edit.php' ) );
                        $num  = '<a href="' . esc_url( $link ) . '">' . $num  . '</a>';
                        $text = '<a href="' . esc_url( $link ) . '">' . $text . '</a>';
                    }
                ?>
 
                <td class="first b b-forums"><?php echo $num; ?></td>
                <td class="t forums"><?php echo $text; ?></td>
 
            </tr>
 
            <tr>
 
                <?php
                    $num  = $r['topic_count'];
                    $text = _n( 'Discussion', 'Discussions', $r['topic_count'], 'buddyboss' );
                    if ( current_user_can( 'publish_topics' ) ) {
                        $link = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit.php' ) );
                        $num  = '<a href="' . esc_url( $link ) . '">' . $num  . '</a>';
                        $text = '<a href="' . esc_url( $link ) . '">' . $text . '</a>';
                    }
                ?>
 
                <td class="first b b-topics"><?php echo $num; ?></td>
                <td class="t topics"><?php echo $text; ?></td>
 
            </tr>
 
            <?php if ( bbp_allow_topic_tags() ) : ?>
 
                <tr>
 
                    <?php
                        $num  = $r['topic_tag_count'];
                        $text = _n( 'Discussion Tag', 'Discussion Tags', $r['topic_tag_count'], 'buddyboss' );
                        if ( current_user_can( 'manage_topic_tags' ) ) {
                            $link = add_query_arg( array( 'taxonomy' => bbp_get_topic_tag_tax_id(), 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit-tags.php' ) );
                            $num  = '<a href="' . esc_url( $link ) . '">' . $num  . '</a>';
                            $text = '<a href="' . esc_url( $link ) . '">' . $text . '</a>';
                        }
                    ?>
 
                    <td class="first b b-topic_tags"><span class="total-count"><?php echo $num; ?></span></td>
                    <td class="t topic_tags"><?php echo $text; ?></td>
 
                </tr>
 
            <?php endif; ?>
 
            <tr>
 
                <?php
                    $num  = $r['reply_count'];
                    $text = _n( 'Reply', 'Replies', $r['reply_count'], 'buddyboss' );
                    if ( current_user_can( 'publish_replies' ) ) {
                        $link = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), get_admin_url( null, 'edit.php' ) );
                        $num  = '<a href="' . esc_url( $link ) . '">' . $num  . '</a>';
                        $text = '<a href="' . esc_url( $link ) . '">' . $text . '</a>';
                    }
                ?>
 
                <td class="first b b-replies"><?php echo $num; ?></td>
                <td class="t replies"><?php echo $text; ?></td>
 
            </tr>
 
            <?php do_action( 'bbp_dashboard_widget_right_now_content_table_end' ); ?>
 
        </table>
 
    </div>
 
 
    <div class="table table_discussion">
 
        <p class="sub"><?php esc_html_e( 'Users &amp; Moderation', 'buddyboss' ); ?></p>
 
        <table>
 
            <tr class="first">
 
                <?php
                    $num  = $r['user_count'];
                    $text = _n( 'User', 'Users', $r['user_count'], 'buddyboss' );
                    if ( current_user_can( 'edit_users' ) ) {
                        $link = get_admin_url( null, 'users.php' );
                        $num  = '<a href="' . esc_url( $link ) . '">' . $num  . '</a>';
                        $text = '<a href="' . esc_url( $link ) . '">' . $text . '</a>';
                    }
                ?>
 
                <td class="b b-users"><span class="total-count"><?php echo $num; ?></span></td>
                <td class="last t users"><?php echo $text; ?></td>
 
            </tr>
 
            <?php if ( isset( $r['topic_count_hidden'] ) ) : ?>
 
                <tr>
 
                    <?php
                        $num  = $r['topic_count_hidden'];
                        $text = _n( 'Hidden Discussion', 'Hidden Discussions', $r['topic_count_hidden'], 'buddyboss' );
                        $link = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit.php' ) );
                        if ( '0' !== $num ) {
                            $link = add_query_arg( array( 'post_status' => bbp_get_spam_status_id() ), $link );
                        }
                        $num  = '<a href="' . esc_url( $link ) . '" title="' . esc_attr( $r['hidden_topic_title'] ) . '">' . $num  . '</a>';
                        $text = '<a class="waiting" href="' . esc_url( $link ) . '" title="' . esc_attr( $r['hidden_topic_title'] ) . '">' . $text . '</a>';
                    ?>
 
                    <td class="b b-hidden-topics"><?php echo $num; ?></td>
                    <td class="last t hidden-replies"><?php echo $text; ?></td>
 
                </tr>
 
            <?php endif; ?>
 
            <?php if ( isset( $r['reply_count_hidden'] ) ) : ?>
 
                <tr>
 
                    <?php
                        $num  = $r['reply_count_hidden'];
                        $text = _n( 'Hidden Reply', 'Hidden Replies', $r['reply_count_hidden'], 'buddyboss' );
                        $link = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), get_admin_url( null, 'edit.php' ) );
                        if ( '0' !== $num ) {
                            $link = add_query_arg( array( 'post_status' => bbp_get_spam_status_id() ), $link );
                        }
                        $num  = '<a href="' . esc_url( $link ) . '" title="' . esc_attr( $r['hidden_reply_title'] ) . '">' . $num  . '</a>';
                        $text = '<a class="waiting" href="' . esc_url( $link ) . '" title="' . esc_attr( $r['hidden_reply_title'] ) . '">' . $text . '</a>';
                    ?>
 
                    <td class="b b-hidden-replies"><?php echo $num; ?></td>
                    <td class="last t hidden-replies"><?php echo $text; ?></td>
 
                </tr>
 
            <?php endif; ?>
 
            <?php if ( bbp_allow_topic_tags() && isset( $r['empty_topic_tag_count'] ) ) : ?>
 
                <tr>
 
                    <?php
                        $num  = $r['empty_topic_tag_count'];
                        $text = _n( 'Empty Discussion Tag', 'Empty Discussion Tags', $r['empty_topic_tag_count'], 'buddyboss' );
                        $link = add_query_arg( array( 'taxonomy' => bbp_get_topic_tag_tax_id(), 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit-tags.php' ) );
                        $num  = '<a href="' . esc_url( $link ) . '">' . $num  . '</a>';
                        $text = '<a class="waiting" href="' . esc_url( $link ) . '">' . $text . '</a>';
                    ?>
 
                    <td class="b b-hidden-topic-tags"><?php echo $num; ?></td>
                    <td class="last t hidden-topic-tags"><?php echo $text; ?></td>
 
                </tr>
 
            <?php endif; ?>
 
            <?php do_action( 'bbp_dashboard_widget_right_now_discussion_table_end' ); ?>
 
        </table>
 
    </div>
 
    <?php do_action( 'bbp_dashboard_widget_right_now_table_end' ); ?>
 
    <br class="clear" />
 
    <?php
 
    do_action( 'bbp_dashboard_widget_right_now_end' );
}

Changelog

Changelog
Version Description
bbPress (r2770) Introduced.

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.