Changeset 5483 for branches/1.5/bp-members/bp-members-adminbar.php
- Timestamp:
- 12/10/2011 06:16:23 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/1.5/bp-members/bp-members-adminbar.php
r5283 r5483 13 13 14 14 /** 15 * Adjust the admin bar menus based on which WordPress version this is 16 * 17 * @since BuddyPress (1.5.2) 18 */ 19 function bp_members_admin_bar_version_check() { 20 21 if ( '3.2' == bp_get_major_wp_version() ) { 22 add_action( 'bp_setup_admin_bar', 'bp_members_admin_bar_my_account_menu', 4 ); 23 add_action( 'bp_setup_admin_bar', 'bp_members_admin_bar_notifications_menu', 5 ); 24 add_action( 'bp_setup_admin_bar', 'bp_members_admin_bar_user_admin_menu', 99 ); 25 add_action( 'bp_setup_admin_bar', 'bp_members_admin_bar_my_account_logout', 9999 ); 26 } elseif ( '3.3' == bp_get_major_wp_version() ) { 27 add_action( 'bp_setup_admin_bar', 'bp_members_admin_bar_my_account_menu', 4 ); 28 add_action( 'bp_setup_admin_bar', 'bp_members_admin_bar_notifications_menu', 5 ); 29 add_action( 'admin_bar_menu', 'bp_members_admin_bar_user_admin_menu', 400 ); 30 } 31 } 32 add_action( 'admin_bar_menu', 'bp_members_admin_bar_version_check', 4 ); 33 34 /** 15 35 * Add the "My Account" menu and all submenus. 16 36 * … … 18 38 */ 19 39 function bp_members_admin_bar_my_account_menu() { 20 global $bp, $wp_admin_bar ;40 global $bp, $wp_admin_bar, $wp_version; 21 41 22 42 // Bail if this is an ajax request … … 27 47 if ( is_user_logged_in() ) { 28 48 29 // User avatar 30 $avatar = bp_core_fetch_avatar( array( 31 'item_id' => $bp->loggedin_user->id, 32 'email' => $bp->loggedin_user->userdata->user_email, 33 'width' => 16, 34 'height' => 16 35 ) ); 36 37 // Unique ID for the 'My Account' menu 38 $bp->my_account_menu_id = ( ! empty( $avatar ) ) ? 'my-account-with-avatar' : 'my-account'; 39 40 // Create the main 'My Account' menu 41 $wp_admin_bar->add_menu( array( 42 'id' => $bp->my_account_menu_id, 43 'title' => $avatar . bp_get_loggedin_user_fullname(), 44 'href' => $bp->loggedin_user->domain 45 ) ); 49 if ( '3.2' == bp_get_major_wp_version() ) { 50 51 // User avatar 52 $avatar = bp_core_fetch_avatar( array( 53 'item_id' => $bp->loggedin_user->id, 54 'email' => $bp->loggedin_user->userdata->user_email, 55 'width' => 16, 56 'height' => 16 57 ) ); 58 59 // Unique ID for the 'My Account' menu 60 $bp->my_account_menu_id = ( ! empty( $avatar ) ) ? 'my-account-with-avatar' : 'my-account'; 61 62 // Create the main 'My Account' menu 63 $wp_admin_bar->add_menu( array( 64 'id' => $bp->my_account_menu_id, 65 'title' => $avatar . bp_get_loggedin_user_fullname(), 66 'href' => $bp->loggedin_user->domain 67 ) ); 68 69 } else { 70 71 // Unique ID for the 'My Account' menu 72 $bp->my_account_menu_id = 'my-account-buddypress'; 73 74 // Create the main 'My Account' menu 75 $wp_admin_bar->add_menu( array( 76 'parent' => 'my-account', 77 'id' => $bp->my_account_menu_id, 78 'href' => $bp->loggedin_user->domain, 79 'group' => true, 80 'meta' => array( 'class' => 'ab-sub-secondary' ) 81 ) ); 82 } 46 83 47 84 // Show login and sign-up links … … 67 104 } 68 105 } 69 add_action( 'bp_setup_admin_bar', 'bp_members_admin_bar_my_account_menu', 4 );70 106 71 107 /** … … 86 122 return false; 87 123 88 // User avatar 89 $avatar = bp_core_fetch_avatar( array( 90 'item_id' => $bp->displayed_user->id, 91 'email' => $bp->displayed_user->userdata->user_email, 92 'width' => 16, 93 'height' => 16 94 ) ); 95 96 // Unique ID for the 'My Account' menu 97 $bp->user_admin_menu_id = ( ! empty( $avatar ) ) ? 'user-admin-with-avatar' : 'user-admin'; 98 99 // Add the top-level User Admin button 100 $wp_admin_bar->add_menu( array( 101 'id' => $bp->user_admin_menu_id, 102 'title' => $avatar . bp_get_displayed_user_fullname(), 103 'href' => bp_displayed_user_domain() 104 ) ); 124 if ( '3.2' == bp_get_major_wp_version() ) { 125 126 // User avatar 127 $avatar = bp_core_fetch_avatar( array( 128 'item_id' => $bp->displayed_user->id, 129 'email' => $bp->displayed_user->userdata->user_email, 130 'width' => 16, 131 'height' => 16 132 ) ); 133 134 // Unique ID for the 'My Account' menu 135 $bp->user_admin_menu_id = ( ! empty( $avatar ) ) ? 'user-admin-with-avatar' : 'user-admin'; 136 137 // Add the top-level User Admin button 138 $wp_admin_bar->add_menu( array( 139 'id' => $bp->user_admin_menu_id, 140 'title' => $avatar . bp_get_displayed_user_fullname(), 141 'href' => bp_displayed_user_domain() 142 ) ); 143 144 } elseif ( '3.3' == bp_get_major_wp_version() ) { 145 146 // Unique ID for the 'My Account' menu 147 $bp->user_admin_menu_id = 'user-admin'; 148 149 // Add the top-level User Admin button 150 $wp_admin_bar->add_menu( array( 151 'id' => $bp->user_admin_menu_id, 152 'title' => __( 'Edit Member', 'buddypress' ), 153 'href' => bp_displayed_user_domain() 154 ) ); 155 } 105 156 106 157 // User Admin > Edit this user's profile … … 148 199 ) ); 149 200 } 150 add_action( 'bp_setup_admin_bar', 'bp_members_admin_bar_user_admin_menu', 99 );151 201 152 202 /** … … 168 218 } 169 219 170 // Add the top-level Notifications button 171 $wp_admin_bar->add_menu( array( 172 'id' => 'bp-notifications', 173 'title' => $menu_title, 174 'href' => bp_loggedin_user_domain() 175 ) ); 220 if ( '3.2' == bp_get_major_wp_version() ) { 221 222 // Add the top-level Notifications button 223 $wp_admin_bar->add_menu( array( 224 'id' => 'bp-notifications', 225 'title' => $menu_title, 226 'href' => bp_loggedin_user_domain() 227 ) ); 228 229 } elseif ( '3.3' == bp_get_major_wp_version() ) { 230 231 // Add the top-level Notifications button 232 $wp_admin_bar->add_menu( array( 233 'parent' => 'top-secondary', 234 'id' => 'bp-notifications', 235 'title' => $menu_title, 236 'href' => bp_loggedin_user_domain() 237 ) ); 238 } 176 239 177 240 if ( !empty( $notifications ) ) { … … 195 258 return; 196 259 } 197 add_action( 'bp_setup_admin_bar', 'bp_members_admin_bar_notifications_menu', 999 );198 260 199 261 /** … … 222 284 } 223 285 } 224 add_action( 'bp_setup_admin_bar', 'bp_members_admin_bar_my_account_logout', 9999 );225 286 226 287 ?>
Note: See TracChangeset
for help on using the changeset viewer.