Skip to:
Content

bbPress.org


Ignore:
Timestamp:
02/10/2014 04:48:36 PM (12 years ago)
Author:
johnjamesjacoby
Message:

Deprecate dashboard metabox, and append forum statistics to existing "At a Glance" metabox instead. Fixes #2544.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/admin/metaboxes.php

    r5169 r5268  
    1111
    1212/**
     13 * Filter the Dashboard "at a glance" items and append bbPress elements to it.
     14 *
     15 * @since bbPress (r5268)
     16 *
     17 * @param array $elements
     18 * @return array
     19 */
     20function bbp_dashboard_at_a_glance( $elements = array() ) {
     21
     22    // Get the statistics
     23    $r = bbp_get_statistics();
     24
     25    // Forums
     26    if ( current_user_can( 'publish_forums' ) ) {
     27        $link       = add_query_arg( array( 'post_type' => bbp_get_forum_post_type() ), get_admin_url( null, 'edit.php' ) );
     28        $text       = sprintf( _n( '%d Forum', '%d Forums', $r['forum_count'], 'bbpress' ), $r['forum_count'] );
     29        $elements[] = '<a href="' . esc_url( $link ) . '" class="bbp-glance-forums">' . esc_html( $text ) . '</a>';
     30    }
     31   
     32    // Topics
     33    if ( current_user_can( 'publish_topics' ) ) {
     34        $link       = add_query_arg( array( 'post_type' => bbp_get_topic_post_type() ), get_admin_url( null, 'edit.php' ) );
     35        $text       = sprintf( _n( '%d Topic', '%d Topics', $r['topic_count'], 'bbpress' ), $r['topic_count'] );
     36        $elements[] = '<a href="' . esc_url( $link ) . '" class="bbp-glance-topics">' . esc_html( $text ) . '</a>';
     37    }
     38
     39    // Replies
     40    if ( current_user_can( 'publish_replies' ) ) {
     41        $link       = add_query_arg( array( 'post_type' => bbp_get_reply_post_type() ), get_admin_url( null, 'edit.php' ) );;
     42        $text       = sprintf( _n( '%d Reply', '%d Replies', $r['reply_count'], 'bbpress' ), $r['reply_count'] );
     43        $elements[] = '<a href="' . esc_url( $link ) . '" class="bbp-glance-replies">' . esc_html( $text ) . '</a>';
     44    }
     45
     46    // Topic Tags
     47    if ( bbp_allow_topic_tags() && current_user_can( 'manage_topic_tags' ) ) {
     48        $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' ) );
     49        $text       = sprintf( _n( '%d Topic Tags', '%d Topic Tags', $r['topic_tag_count'], 'bbpress' ), $r['topic_tag_count'] );
     50        $elements[] = '<a href="' . esc_url( $link ) . '" class="bbp-glance-topic-tags">' . esc_html( $text ) . '</a>';
     51    }
     52
     53    // Filter and return
     54    return apply_filters( 'bbp_dashboard_at_a_glance', $elements, $r );
     55}
     56
     57/**
    1358 * bbPress Dashboard Right Now Widget
    1459 *
     
    1661 *
    1762 * @since bbPress (r2770)
     63 * @deprecated bbPress (r5268)
    1864 *
    1965 * @uses bbp_get_version() To get the current bbPress version
Note: See TracChangeset for help on using the changeset viewer.