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
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 & 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
| 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.