bbp_filter_dashboard_glance_items( array $elements = array() )
Filter the Dashboard “at a glance” items and append bbPress elements to it.
Description Description
Parameters Parameters
- $elements
-
(Optional)
Default value: array()
Return Return
(array)
Source Source
File: includes/admin/metaboxes.php
function bbp_filter_dashboard_glance_items( $elements = array() ) {
// Bail if user cannot spectate
if ( ! current_user_can( 'spectate' ) ) {
return $elements;
}
// Get the statistics
$r = bbp_get_statistics( array(
'count_pending_topics' => false,
'count_private_topics' => false,
'count_spammed_topics' => false,
'count_trashed_topics' => false,
'count_pending_replies' => false,
'count_private_replies' => false,
'count_spammed_replies' => false,
'count_trashed_replies' => false,
'count_empty_tags' => false
) );
// Users
if ( isset( $r['user_count'] ) ) {
$link = admin_url( 'users.php' );
$text = sprintf( _n( '%s User', '%s Users', $r['user_count_int'], 'bbpress' ), $r['user_count'] );
$elements[] = current_user_can( 'edit_users' )
? '<a href="' . esc_url( $link ) . '" class="bbp-glance-users">' . esc_html( $text ) . '</a>'
: esc_html( $text );
}
// Forums
if ( isset( $r['forum_count'] ) ) {
$link = add_query_arg( array( 'post_type' => bbp_get_forum_post_type() ), admin_url( 'edit.php' ) );
$text = sprintf( _n( '%s Forum', '%s Forums', $r['forum_count_int'], 'bbpress' ), $r['forum_count'] );
$elements[] = current_user_can( 'publish_forums' )
? '<a href="' . esc_url( $link ) . '" class="bbp-glance-forums">' . esc_html( $text ) . '</a>'
: esc_html( $text );
}
// Topics
if ( isset( $r['topic_count'] ) ) {
$link = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit.php' ) );
$text = sprintf( _n( '%s Topic', '%s Topics', $r['topic_count_int'], 'bbpress' ), $r['topic_count'] );
$elements[] = current_user_can( 'publish_topics' )
? '<a href="' . esc_url( $link ) . '" class="bbp-glance-topics">' . esc_html( $text ) . '</a>'
: esc_html( $text );
}
// Replies
if ( isset( $r['reply_count'] ) ) {
$link = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), admin_url( 'edit.php' ) );
$text = sprintf( _n( '%s Reply', '%s Replies', $r['reply_count_int'], 'bbpress' ), $r['reply_count'] );
$elements[] = current_user_can( 'publish_replies' )
? '<a href="' . esc_url( $link ) . '" class="bbp-glance-replies">' . esc_html( $text ) . '</a>'
: esc_html( $text );
}
// Topic Tags
if ( bbp_allow_topic_tags() && isset( $r['topic_tag_count'] ) ) {
$link = add_query_arg( array( 'taxonomy' => bbp_get_topic_tag_tax_id(), 'post_type' => bbp_get_topic_post_type() ), admin_url( 'edit-tags.php' ) );
$text = sprintf( _n( '%s Topic Tag', '%s Topic Tags', $r['topic_tag_count_int'], 'bbpress' ), $r['topic_tag_count'] );
$elements[] = current_user_can( 'manage_topic_tags' )
? '<a href="' . esc_url( $link ) . '" class="bbp-glance-topic-tags">' . esc_html( $text ) . '</a>'
: esc_html( $text );
}
// Filter & return
return apply_filters( 'bbp_dashboard_at_a_glance', $elements, $r );
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.6.0 | Introduced. |