Skip to:
Content

bbPress.org

Changeset 5268


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.

Location:
trunk/includes/admin
Files:
4 edited

Legend:

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

    r4910 r5268  
    8383// Add sample permalink filter
    8484add_filter( 'post_type_link', 'bbp_filter_sample_permalink', 10, 4 );
     85
     86// Add quick stats to dashboard glance elements
     87add_filter( 'dashboard_glance_items', 'bbp_dashboard_at_a_glance' );
    8588
    8689/**
  • trunk/includes/admin/admin.php

    r5255 r5268  
    137137        /** General Actions ***************************************************/
    138138
    139         add_action( 'bbp_admin_menu',              array( $this, 'admin_menus'                )     ); // Add menu item to settings menu
    140         add_action( 'bbp_admin_head',              array( $this, 'admin_head'                 )     ); // Add some general styling to the admin area
    141         add_action( 'bbp_admin_notices',           array( $this, 'activation_notice'          )     ); // Add notice if not using a bbPress theme
    142         add_action( 'bbp_register_admin_style',    array( $this, 'register_admin_style'       )     ); // Add green admin style
    143         add_action( 'bbp_register_admin_settings', array( $this, 'register_admin_settings'    )     ); // Add settings
    144         add_action( 'bbp_activation',              array( $this, 'new_install'                )     ); // Add menu item to settings menu
    145         add_action( 'admin_enqueue_scripts',       array( $this, 'enqueue_styles'             )     ); // Add enqueued CSS
    146         add_action( 'admin_enqueue_scripts',       array( $this, 'enqueue_scripts'            )     ); // Add enqueued JS
    147         add_action( 'wp_dashboard_setup',          array( $this, 'dashboard_widget_right_now' )     ); // Forums 'Right now' Dashboard widget
    148         add_action( 'admin_bar_menu',              array( $this, 'admin_bar_about_link'       ), 15 ); // Add a link to bbPress about page to the admin bar
     139        add_action( 'bbp_admin_menu',              array( $this, 'admin_menus'             )     ); // Add menu item to settings menu
     140        add_action( 'bbp_admin_head',              array( $this, 'admin_head'              )     ); // Add some general styling to the admin area
     141        add_action( 'bbp_admin_notices',           array( $this, 'activation_notice'       )     ); // Add notice if not using a bbPress theme
     142        add_action( 'bbp_register_admin_style',    array( $this, 'register_admin_style'    )     ); // Add green admin style
     143        add_action( 'bbp_register_admin_settings', array( $this, 'register_admin_settings' )     ); // Add settings
     144        add_action( 'bbp_activation',              array( $this, 'new_install'             )     ); // Add menu item to settings menu
     145        add_action( 'admin_enqueue_scripts',       array( $this, 'enqueue_styles'          )     ); // Add enqueued CSS
     146        add_action( 'admin_enqueue_scripts',       array( $this, 'enqueue_scripts'         )     ); // Add enqueued JS
     147        add_action( 'admin_bar_menu',              array( $this, 'admin_bar_about_link'    ), 15 ); // Add a link to bbPress about page to the admin bar
    149148
    150149        /** Ajax **************************************************************/
     
    520519        // Add a few links to the existing links array
    521520        return array_merge( $links, $new_links );
    522     }
    523 
    524     /**
    525      * Add the 'Right now in Forums' dashboard widget
    526      *
    527      * @since bbPress (r2770)
    528      *
    529      * @uses wp_add_dashboard_widget() To add the dashboard widget
    530      */
    531     public static function dashboard_widget_right_now() {
    532         wp_add_dashboard_widget( 'bbp-dashboard-right-now', __( 'Right Now in Forums', 'bbpress' ), 'bbp_dashboard_widget_right_now' );
    533521    }
    534522
  • trunk/includes/admin/css/admin.css

    r5255 r5268  
    2828        left: 0;
    2929    }
     30
     31/* Dashicons */
     32
     33#dashboard_right_now a.bbp-glance-forums:before,
     34#adminmenu #menu-posts-forum .wp-menu-image:before {
     35    content: "\f449";
     36}
     37
     38#dashboard_right_now a.bbp-glance-topics:before,
     39#adminmenu #menu-posts-topic .wp-menu-image:before {
     40    content: "\f450";
     41}
     42
     43#dashboard_right_now a.bbp-glance-replies:before,
     44#adminmenu #menu-posts-reply .wp-menu-image:before {
     45    content: "\f451";
     46}
     47
     48#dashboard_right_now a.bbp-glance-topic-tags:before {
     49    content: '\f323';
     50}
     51
     52/* Deprecated Dashboard Metabox */
    3053
    3154#bbp-dashboard-right-now p.sub,
     
    153176        clear: left;
    154177    }
    155 
    156 /* Dashicons */
    157 #adminmenu #menu-posts-forum .wp-menu-image:before {
    158     content: "\f449";
    159 }
    160 
    161 #adminmenu #menu-posts-topic .wp-menu-image:before {
    162     content: "\f450";
    163 }
    164 
    165 #adminmenu #menu-posts-reply .wp-menu-image:before {
    166     content: "\f451";
    167 }
    168 
    169 /* Ratio 2x */
    170 @media only screen and (-webkit-min-device-pixel-ratio: 1.5) {
    171     .bbp-badge {
    172         background-image: url('../images/badge-2x.png');
    173         background-size: 173px 194px;
    174     }
    175 }
  • 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.