Skip to:
Content

BuddyPress.org

Changeset 5289


Ignore:
Timestamp:
11/06/2011 06:52:09 AM (15 years ago)
Author:
johnjamesjacoby
Message:

First pass at updating the admin/toolbar for WordPress 3.3. See #3596.

Location:
trunk
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-adminbar.php

    r5213 r5289  
    11<?php
     2
    23/**
    34 * BuddyPress Core Admin Bar
     
    1617
    1718/**
    18  * Unhook the WordPress core menus.
     19 * Adds the secondary BuddyPress area to the my-account menu
    1920 *
    20  * @since BuddyPress (r4151)
    21  *
    22  * @uses remove_action
    23  * @uses is_network_admin()
    24  * @uses is_user_admin()
     21 * @since BuddyPress 1.6
     22 * @global WP_Admin_Bar $wp_admin_bar
     23 * @return If doing ajax
    2524 */
    26 function bp_admin_bar_remove_wp_menus() {
     25function bp_admin_bar_my_account_secondary() {
     26        global $wp_admin_bar;
    2727
    28         /**
    29          * WP 3.2 hooks
    30          */
    31         remove_action( 'admin_bar_menu', 'wp_admin_bar_my_account_menu', 10 );
    32         remove_action( 'admin_bar_menu', 'wp_admin_bar_my_sites_menu', 20 );
    33         remove_action( 'admin_bar_menu', 'wp_admin_bar_dashboard_view_site_menu', 25 );
    34         remove_action( 'admin_bar_menu', 'wp_admin_bar_shortlink_menu', 80 );
     28        // Bail if this is an ajax request
     29        if ( defined( 'DOING_AJAX' ) )
     30                return;
    3531
    36         // Don't show the 'Edit Page' menu on BP pages
    37         if ( !bp_is_blog_page() )
    38                 remove_action( 'admin_bar_menu', 'wp_admin_bar_edit_menu', 30 );
     32        // Only add menu for logged in user
     33        if ( is_user_logged_in() ) {
    3934
    40         if ( !is_network_admin() && !is_user_admin() ) {
    41                 remove_action( 'admin_bar_menu', 'wp_admin_bar_comments_menu', 50 );
    42                 remove_action( 'admin_bar_menu', 'wp_admin_bar_appearance_menu', 60 );
    43                 remove_action( 'admin_bar_menu', 'wp_admin_bar_updates_menu', 70 );
    44         }
    45 
    46         /**
    47          * WP 3.3+
    48          */
    49         remove_action( 'admin_bar_menu', 'wp_admin_bar_blog_front_menu', 30 );
    50         remove_action( 'admin_bar_menu', 'wp_admin_bar_shortlink_menu', 80 );
    51 
    52         // Menus specific to blog posts shouldn't show on BP pages
    53         if ( !bp_is_blog_page() && !is_network_admin() && !is_admin() ) {
    54                 remove_action( 'admin_bar_menu', 'wp_admin_bar_edit_menu', 50 );
    55                 remove_action( 'admin_bar_menu', 'wp_admin_bar_comments_menu', 60 );
    56         }
    57 
    58         // Don't show the Updates menu on the front end
    59         if ( !is_network_admin() && !is_admin() ) {
    60                 remove_action( 'admin_bar_menu', 'wp_admin_bar_updates_menu', 40 );
     35                // Add secondary parent item for all BuddyPress components
     36                $wp_admin_bar->add_menu( array(
     37                        'parent' => 'my-account',
     38                        'id'     => 'my-account-buddypress',
     39                        'title'  => '&nbsp;',
     40                        'meta'   => array(
     41                                'class' => 'secondary',
     42                        )
     43                ) );
    6144        }
    6245}
    63 add_action( 'bp_init', 'bp_admin_bar_remove_wp_menus', 2 );
    64 
    65 /**
    66  * Add a menu for the root site of this BuddyPress network
    67  *
    68  * @global type $bp
    69  * @global type $wp_admin_bar
    70  * @return If in ajax
    71  */
    72 function bp_admin_bar_root_site() {
    73         global $bp, $wp_admin_bar;
    74 
    75         // Create the root blog menu
    76         $wp_admin_bar->add_menu( array(
    77                 'id'    => 'bp-root-blog',
    78                 'title' => get_blog_option( bp_get_root_blog_id(), 'blogname' ),
    79                 'href'  => bp_get_root_domain()
    80         ) );
    81 
    82         // Logged in user
    83         if ( is_user_logged_in() ) {
    84 
    85                 // Dashboard links
    86                 if ( is_super_admin() ) {
    87 
    88                         // Add site admin link
    89                         $wp_admin_bar->add_menu( array(
    90                                 'id' => 'dashboard',
    91                                 'parent' => 'bp-root-blog',
    92                                 'title' => __( 'Admin Dashboard', 'buddypress' ),
    93                                 'href' => get_admin_url( bp_get_root_blog_id() )
    94                         ) );
    95 
    96                         // Add network admin link
    97                         if ( is_multisite() ) {
    98 
    99                                 // Link to the network admin dashboard
    100                                 $wp_admin_bar->add_menu( array(
    101                                         'id' => 'network-dashboard',
    102                                         'parent' => 'bp-root-blog',
    103                                         'title' => __( 'Network Dashboard', 'buddypress' ),
    104                                         'href' => network_admin_url()
    105                                 ) );
    106                         }
    107                 }
    108         }
    109 }
    110 add_action( 'admin_bar_menu', 'bp_admin_bar_root_site', 15 );
    111 
    112 /**
    113  * Add the "My Sites/[Site Name]" menu and all submenus.
    114  */
    115 function bp_admin_bar_my_sites_menu() {
    116         global $wpdb, $wp_admin_bar;
    117 
    118         /* Add the 'My Sites' menu if the user has more than one site. */
    119         if ( count( $wp_admin_bar->user->blogs ) <= 1 )
    120                 return;
    121 
    122         $wp_admin_bar->add_menu( array( 'id' => 'my-blogs', 'title' => __( 'My Sites' ), 'href' => admin_url( 'my-sites.php' ) ) );
    123 
    124         $default = includes_url( 'images/wpmini-blue.png' );
    125 
    126         foreach ( (array)$wp_admin_bar->user->blogs as $blog ) {
    127                 // @todo Replace with some favicon lookup.
    128                 //$blavatar = '<img src="' . esc_url( blavatar_url( blavatar_domain( $blog->siteurl ), 'img', 16, $default ) ) . '" alt="Blavatar" width="16" height="16" />';
    129                 $blavatar = '<img src="' . esc_url( $default ) . '" alt="' . esc_attr__( 'Blavatar' ) . '" width="16" height="16" class="blavatar"/>';
    130 
    131                 $blogname = empty( $blog->blogname ) ? $blog->domain : $blog->blogname;
    132 
    133                 $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-' . $blog->userblog_id, 'title' => $blavatar . $blogname, 'href' => get_admin_url( $blog->userblog_id ) ) );
    134                 $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-d', 'title' => __( 'Dashboard' ), 'href' => get_admin_url( $blog->userblog_id ) ) );
    135 
    136                 if ( current_user_can_for_blog( $blog->userblog_id, 'edit_posts' ) ) {
    137                         $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-n', 'title' => __( 'New Post' ), 'href' => get_admin_url( $blog->userblog_id, 'post-new.php' ) ) );
    138                         $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-c', 'title' => __( 'Manage Comments' ), 'href' => get_admin_url( $blog->userblog_id, 'edit-comments.php' ) ) );
    139                 }
    140 
    141                 $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-v', 'title' => __( 'Visit Site' ), 'href' => get_home_url( $blog->userblog_id ) ) );
    142         }
    143 }
    144 add_action( 'admin_bar_menu', 'bp_admin_bar_my_sites_menu', 17 );
    145 
    146 /**
    147  * Add edit comments link with awaiting moderation count bubble
    148  */
    149 function bp_admin_bar_comments_menu( $wp_admin_bar ) {
    150         global $wp_admin_bar;
    151 
    152         if ( !current_user_can( 'edit_posts' ) )
    153                 return;
    154 
    155         $awaiting_mod = wp_count_comments();
    156         $awaiting_mod = $awaiting_mod->moderated;
    157 
    158         $awaiting_mod = $awaiting_mod ? "<span id='ab-awaiting-mod' class='pending-count'>" . number_format_i18n( $awaiting_mod ) . "</span>" : '';
    159         $wp_admin_bar->add_menu( array( 'parent' => 'dashboard', 'id' => 'comments', 'title' => sprintf( __( 'Comments %s' ), $awaiting_mod ), 'href' => admin_url( 'edit-comments.php' ) ) );
    160 }
    161 add_action( 'bp_setup_admin_bar', 'bp_admin_bar_comments_menu', 3 );
    162 
    163 /**
    164  * Add "Appearance" menu with widget and nav menu submenu
    165  */
    166 function bp_admin_bar_appearance_menu() {
    167         global $wp_admin_bar;
    168 
    169         // You can have edit_theme_options but not switch_themes.
    170         if ( !current_user_can( 'switch_themes' ) && !current_user_can( 'edit_theme_options' ) )
    171                 return;
    172 
    173         $wp_admin_bar->add_menu( array( 'parent' => 'dashboard', 'id' => 'appearance', 'title' => __( 'Appearance' ), 'href' => admin_url( 'themes.php' ) ) );
    174 
    175         if ( !current_user_can( 'edit_theme_options' ) )
    176                 return;
    177 
    178         if ( current_user_can( 'switch_themes' ) )
    179                 $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'themes', 'title' => __( 'Themes' ), 'href' => admin_url( 'themes.php' ) ) );
    180 
    181         if ( current_theme_supports( 'widgets' ) )
    182                 $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'widgets', 'title' => __( 'Widgets' ), 'href' => admin_url( 'widgets.php' ) ) );
    183 
    184         if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) )
    185                 $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'menus', 'title' => __( 'Menus' ), 'href' => admin_url( 'nav-menus.php' ) ) );
    186 
    187         if ( current_theme_supports( 'custom-background' ) )
    188                 $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'background', 'title' => __( 'Background' ), 'href' => admin_url( 'themes.php?page=custom-background' ) ) );
    189 
    190         if ( current_theme_supports( 'custom-header' ) )
    191                 $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'header', 'title' => __( 'Header' ), 'href' => admin_url( 'themes.php?page=custom-header' ) ) );
    192 }
    193 add_action( 'bp_setup_admin_bar', 'bp_admin_bar_appearance_menu', 3 );
    194 
    195 /**
    196  * Provide an update link if theme/plugin/core updates are available
    197  */
    198 function bp_admin_bar_updates_menu() {
    199         global $wp_admin_bar;
    200 
    201         if ( !current_user_can( 'install_plugins' ) )
    202                 return;
    203 
    204         $plugin_update_count = $theme_update_count = $wordpress_update_count = 0;
    205         $update_plugins = get_site_transient( 'update_plugins' );
    206         if ( !empty( $update_plugins->response ) )
    207                 $plugin_update_count = count( $update_plugins->response );
    208         $update_themes = get_site_transient( 'update_themes' );
    209         if ( !empty( $update_themes->response ) )
    210                 $theme_update_count = count( $update_themes->response );
    211         /* @todo get_core_updates() is only available on admin page loads
    212           $update_wordpress = get_core_updates( array('dismissed' => false) );
    213           if ( !empty($update_wordpress) && !in_array( $update_wordpress[0]->response, array('development', 'latest') ) )
    214           $wordpress_update_count = 1;
    215          */
    216 
    217         $update_count = $plugin_update_count + $theme_update_count + $wordpress_update_count;
    218 
    219         if ( !$update_count )
    220                 return;
    221 
    222         $update_title = array( );
    223         if ( $wordpress_update_count )
    224                 $update_title[] = sprintf( __( '%d WordPress Update' ), $wordpress_update_count );
    225         if ( $plugin_update_count )
    226                 $update_title[] = sprintf( _n( '%d Plugin Update', '%d Plugin Updates', $plugin_update_count ), $plugin_update_count );
    227         if ( $theme_update_count )
    228                 $update_title[] = sprintf( _n( '%d Theme Update', '%d Theme Updates', $theme_update_count ), $theme_update_count );
    229 
    230         $update_title = !empty( $update_title ) ? esc_attr( implode( ', ', $update_title ) ) : '';
    231 
    232         $update_title = "<span title='$update_title'>";
    233         $update_title .= sprintf( __( 'Updates %s' ), "<span id='ab-updates' class='update-count'>" . number_format_i18n( $update_count ) . '</span>' );
    234         $update_title .= '</span>';
    235 
    236         $wp_admin_bar->add_menu( array( 'parent' => 'dashboard', 'id' => 'updates', 'title' => $update_title, 'href' => network_admin_url( 'update-core.php' ) ) );
    237 }
    238 add_action( 'bp_setup_admin_bar', 'bp_admin_bar_updates_menu', 3 );
     46add_action( 'admin_bar_menu', 'bp_admin_bar_my_account_secondary', 9999 );
    23947
    24048/**
    24149 * Handle the Admin Bar CSS
     50 *
     51 * @since BuddyPress 1.5
    24252 */
    24353function bp_core_load_admin_bar_css() {
    244         global $wp_version;
     54
     55        $version = '2011116';
    24556
    24657        if ( !bp_use_wp_admin_bar() )
     
    25364                $stylesheet = BP_PLUGIN_URL . '/bp-core/css/admin-bar.css';
    25465
    255         wp_enqueue_style( 'bp-admin-bar', apply_filters( 'bp_core_admin_bar_css', $stylesheet ), array( 'admin-bar' ), '20110723' );
     66        wp_enqueue_style( 'bp-admin-bar', apply_filters( 'bp_core_admin_bar_css', $stylesheet ), array( 'admin-bar' ), $version );
    25667
    25768        if ( !is_rtl() )
     
    26374                $stylesheet = BP_PLUGIN_URL . '/bp-core/css/admin-bar-rtl.css';
    26475
    265         wp_enqueue_style( 'bp-admin-bar-rtl', apply_filters( 'bp_core_admin_bar_rtl_css', $stylesheet ), array( 'bp-admin-bar' ), '20110723' );
     76        wp_enqueue_style( 'bp-admin-bar-rtl', apply_filters( 'bp_core_admin_bar_rtl_css', $stylesheet ), array( 'bp-admin-bar' ), $version );
    26677}
    26778add_action( 'bp_init', 'bp_core_load_admin_bar_css' );
     79
    26880?>
  • trunk/bp-core/bp-core-hooks.php

    r5121 r5289  
    1616
    1717// Attach bp_init to WordPress init
    18 add_action( 'init',       'bp_init'                    );
     18add_action( 'init',           'bp_init'                     );
    1919
    2020// Parse the URI and set globals
    21 add_action( 'bp_init',    'bp_core_set_uri_globals', 2 );
     21add_action( 'bp_init',        'bp_core_set_uri_globals', 2 );
    2222
    2323// Setup component globals
    24 add_action( 'bp_init',    'bp_setup_globals',        4 );
     24add_action( 'bp_init',        'bp_setup_globals',         4 );
    2525
    2626// Setup the navigation menu
    27 add_action( 'bp_init',    'bp_setup_nav',            7 );
     27add_action( 'bp_init',        'bp_setup_nav',             7 );
    2828
    2929// Setup the navigation menu
    30 add_action( 'admin_bar_menu',    'bp_setup_admin_bar' );
     30add_action( 'admin_bar_menu', 'bp_setup_admin_bar',      11 );
    3131
    3232// Setup the title
    33 add_action( 'bp_init',    'bp_setup_title',          9 );
     33add_action( 'bp_init',        'bp_setup_title',           9 );
    3434
    3535// Setup widgets
    36 add_action( 'bp_loaded',  'bp_setup_widgets'           );
     36add_action( 'bp_loaded',      'bp_setup_widgets'            );
    3737
    3838// Setup admin bar
    39 add_action( 'bp_loaded',  'bp_core_load_admin_bar'     );
     39add_action( 'bp_loaded',      'bp_core_load_admin_bar'      );
    4040
    4141/** The hooks *****************************************************************/
  • trunk/bp-core/css/admin-bar.css

    r4876 r5289  
    1 #wpadminbar .quicklinks li#wp-admin-bar-my-account ul,#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar ul{left:0;right:auto;}#wpadminbar .quicklinks li#wp-admin-bar-user-admin-with-avatar>a{border-left:none;background:url(../images/admin-bar-sprite.png?d=11122010) top left no-repeat;}#wpadminbar .quicklinks li#wp-admin-bar-user-admin-with-avatar>a img,#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar>a img{width:16px;height:16px;display:inline;border:1px solid #999;vertical-align:middle;margin:-2px 23px 0 -5px;padding:0;background:#eee;float:none;}#wpadminbar .quicklinks li#wp-admin-bar-user-admin-with-avatar ul,#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul{left:30px;}#wpadminbar .quicklinks li#wp-admin-bar-user-admin-with-avatar ul ul,#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul ul{left:0;}#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar>a{border-left:none;background:url(../images/admin-bar-sprite.png?d=11122010) top left no-repeat;}#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar>a img{width:16px;height:16px;display:inline;border:1px solid #999;vertical-align:middle;margin:-2px 23px 0 -5px;padding:0;background:#eee;float:none;}#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul{left:0;}#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul ul{left:0;}#wpadminbar .quicklinks li#wp-admin-bar-my-account a span.count,#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar a span.count,#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications{background:#eee;color:#333;text-shadow:none;display:inline;padding:2px 5px;font-size:10px;font-weight:bold;-moz-border-radius:10px;-khtml-border-radius:10px;-webkit-border-radius:10px;border-radius:10px;}
     1#wpadminbar .quicklinks li#wp-admin-bar-user-admin-with-avatar>a img,#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar>a img{width:16px;height:16px;display:inline;border:1px solid #999;vertical-align:middle;margin:-2px 10px 0 -5px;padding:0;background:#eee;float:none}#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul{left:0}#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul ul{left:0}#wpadminbar .quicklinks li#wp-admin-bar-my-account a span.count,#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar a span.count,#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications{background:#21759b;color:#fff;text-shadow:none;display:inline;padding:2px 5px;font-size:10px;font-weight:bold;-moz-border-radius:10px;-khtml-border-radius:10px;-webkit-border-radius:10px;border-radius:10px}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications{margin:0}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications.alert{background-color:#1fb3dd;color:#fff}#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications>a{padding:0 .5em}
  • trunk/bp-core/css/admin-bar.dev.css

    r4976 r5289  
    1 #wpadminbar .quicklinks li#wp-admin-bar-my-account ul,
    2 #wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar ul {
    3         left: 0;
    4         right: auto;
    5 }
    61
    72/* Displayed User */
    8 #wpadminbar .quicklinks li#wp-admin-bar-user-admin-with-avatar > a {
    9         border-left: none;
    10         background: url(../images/admin-bar-sprite.png?d=11122010) top left no-repeat;
    11 }
    123#wpadminbar .quicklinks li#wp-admin-bar-user-admin-with-avatar > a img,
    134#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar > a img {
     
    178        border: 1px solid #999;
    189        vertical-align: middle;
    19         margin: -2px 23px 0 -5px;
     10        margin: -2px 10px 0 -5px;
    2011        padding: 0;
    2112        background: #eee;
    2213        float: none;
    2314}
    24 #wpadminbar .quicklinks li#wp-admin-bar-user-admin-with-avatar ul,
    25 #wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul {
    26         left: 30px;
    27 }
    28 #wpadminbar .quicklinks li#wp-admin-bar-user-admin-with-avatar ul ul,
    29 #wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul ul {
    30         left: 0;
    31 }
    3215
    3316/* Displayed Group */
    34 #wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar > a {
    35         border-left: none;
    36         background: url(../images/admin-bar-sprite.png?d=11122010) top left no-repeat;
    37 }
    3817#wpadminbar .quicklinks li#wp-admin-bar-group-admin-with-avatar ul {
    3918        left: 0;
     
    4221        left: 0;
    4322}
     23
     24/* Notifications */
    4425#wpadminbar .quicklinks li#wp-admin-bar-my-account a span.count,
    4526#wpadminbar .quicklinks li#wp-admin-bar-my-account-with-avatar a span.count,
    4627#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications {
    47         background: #eee;
    48         color: #333;
     28        background: #21759B;
     29        color: #fff;
    4930        text-shadow: none;
    5031        display: inline;
     
    5738        border-radius: 10px;
    5839}
     40
     41#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications {
     42        margin: 0
     43}
     44
     45#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications.alert {
     46        background-color: #1fb3dd;
     47        color: #fff;
     48}
     49
     50#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications > a {
     51        padding: 0 .5em;
     52}
  • trunk/bp-members/bp-members-adminbar.php

    r5282 r5289  
    3939                // Backward-compatibility will be deprecated at some point.
    4040                if ( version_compare( (float)$wp_version, '3.3', '>=' ) ) {
     41
    4142                        // Stored in the global so we can add menus easily later on
    42                         $bp->my_account_menu_id = 'my-account';
     43                        $bp->my_account_menu_id = 'my-account-buddypress';
    4344
    4445                        $title = bp_get_loggedin_user_fullname() . $avatar;
     
    182183                return false;
    183184
    184         if ( $notifications = bp_core_get_notifications_for_user( bp_loggedin_user_id(), 'object' ) ) {
    185                 $menu_title = sprintf( __( 'Notifications <span id="ab-pending-notifications" class="pending-count">%s</span>', 'buddypress' ), count( $notifications ) );
    186         } else {
    187                 $menu_title = __( 'Notifications', 'buddypress' );
    188         }
     185        $notifications = bp_core_get_notifications_for_user( bp_loggedin_user_id(), 'object' );
     186        $count         = !empty( $notifications ) ? count( $notifications ) : '0';
     187        $alert_class   = (int) $count > 0 ? 'pending-count alert' : 'count no-alert';
     188        $menu_title    = '<span id="ab-pending-notifications" class="' . $alert_class . '">' . $count . '</span>';
    189189
    190190        // Add the top-level Notifications button
     
    192192                'id'    => 'bp-notifications',
    193193                'title' => $menu_title,
    194                 'href'  => bp_loggedin_user_domain()
     194                'href'  => bp_loggedin_user_domain(),
     195                'meta'  => array(
     196                        'class' => 'opposite',
     197                )
    195198        ) );
    196199
     
    217220add_action( 'admin_bar_menu', 'bp_members_admin_bar_notifications_menu', 90 );
    218221
    219 /**
    220  * Make sure the logout link is at the bottom of the "My Account" menu
    221  *
    222  * @since BuddyPress (r4151)
    223  *
    224  * @global obj $bp
    225  * @global obj $wp_admin_bar
    226  */
    227 function bp_members_admin_bar_my_account_logout() {
    228         global $bp, $wp_admin_bar;
    229 
    230         // Bail if this is an ajax request
    231         if ( defined( 'DOING_AJAX' ) )
    232                 return;
    233 
    234         if ( is_user_logged_in() ) {
    235                 // Log out
    236                 $wp_admin_bar->add_menu( array(
    237                         'parent' => $bp->my_account_menu_id,
    238                         'id'     => $bp->my_account_menu_id . '-logout',
    239                         'title'  => __( 'Log Out', 'buddypress' ),
    240                         'href'   => wp_logout_url()
    241                 ) );
    242         }
    243 }
    244 add_action( 'admin_bar_menu', 'bp_members_admin_bar_my_account_logout', 9999 );
    245 
    246222?>
  • trunk/bp-members/bp-members-filters.php

    r4961 r5289  
    4646add_action( 'bp_loaded', 'bp_members_signup_sanitization' );
    4747
     48/**
     49 * Filter the user profile URL to point to BuddyPress profile edit
     50 *
     51 * @since BuddyPress 1.6
     52 *
     53 * @global BuddyPress $bp
     54 * @param string $url
     55 * @param int $user_id
     56 * @param string $scheme
     57 * @return string
     58 */
     59function bp_members_edit_profile_url( $url, $user_id, $scheme = 'admin' ) {
     60        global $bp;
     61
     62        // Default to $url
     63        $profile_link = $url;
     64
     65        // If xprofile is active, use profile domain link
     66        if ( bp_is_active( 'xprofile' ) ) {
     67                $user_domain  = bp_core_get_user_domain( $user_id );
     68                $profile_link = trailingslashit( $user_domain . $bp->profile->slug . '/edit' );
     69        }
     70       
     71        return apply_filters( 'bp_members_edit_profile_url', $profile_link, $url, $user_id, $scheme );
     72}
     73add_filter( 'edit_profile_url', 'bp_members_edit_profile_url', 10, 3 );
     74
    4875?>
Note: See TracChangeset for help on using the changeset viewer.