add_menu( array( 'id' => 'bp-root-blog', 'title' => get_blog_option( bp_get_root_blog_id(), 'blogname' ), 'href' => bp_get_root_domain() ) ); // Logged in user if ( is_user_logged_in() ) { // Dashboard links if ( is_super_admin() ) { // Add site admin link $wp_admin_bar->add_menu( array( 'id' => 'dashboard', 'parent' => 'bp-root-blog', 'title' => __( 'Admin Dashboard', 'buddypress' ), 'href' => get_admin_url( bp_get_root_blog_id() ) ) ); // Add network admin link if ( is_multisite() ) { // Link to the network admin dashboard $wp_admin_bar->add_menu( array( 'id' => 'network-dashboard', 'parent' => 'bp-root-blog', 'title' => __( 'Network Dashboard', 'buddypress' ), 'href' => network_admin_url() ) ); } } } } /** * Add the "My Sites/[Site Name]" menu and all submenus. */ function bp_admin_bar_my_sites_menu() { global $wp_admin_bar; /* Add the 'My Sites' menu if the user has more than one site. */ if ( count( $wp_admin_bar->user->blogs ) <= 1 ) return; $wp_admin_bar->add_menu( array( 'id' => 'my-blogs', 'title' => __( 'My Sites' ), 'href' => admin_url( 'my-sites.php' ) ) ); $default = includes_url( 'images/wpmini-blue.png' ); foreach ( (array)$wp_admin_bar->user->blogs as $blog ) { // @todo Replace with some favicon lookup. //$blavatar = 'Blavatar'; $blavatar = '' . esc_attr__( 'Blavatar' ) . ''; $blogname = empty( $blog->blogname ) ? $blog->domain : $blog->blogname; $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-' . $blog->userblog_id, 'title' => $blavatar . $blogname, 'href' => get_admin_url( $blog->userblog_id ) ) ); $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 ) ) ); if ( current_user_can_for_blog( $blog->userblog_id, 'edit_posts' ) ) { $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' ) ) ); $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' ) ) ); } $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 ) ) ); } } /** * Add edit comments link with awaiting moderation count bubble */ function bp_admin_bar_comments_menu( $wp_admin_bar ) { global $wp_admin_bar; if ( !current_user_can( 'edit_posts' ) ) return; $awaiting_mod = wp_count_comments(); $awaiting_mod = $awaiting_mod->moderated; $awaiting_mod = $awaiting_mod ? "" . number_format_i18n( $awaiting_mod ) . "" : ''; $wp_admin_bar->add_menu( array( 'parent' => 'dashboard', 'id' => 'comments', 'title' => sprintf( __( 'Comments %s' ), $awaiting_mod ), 'href' => admin_url( 'edit-comments.php' ) ) ); } /** * Add "Appearance" menu with widget and nav menu submenu */ function bp_admin_bar_appearance_menu() { global $wp_admin_bar; // You can have edit_theme_options but not switch_themes. if ( !current_user_can( 'switch_themes' ) && !current_user_can( 'edit_theme_options' ) ) return; $wp_admin_bar->add_menu( array( 'parent' => 'dashboard', 'id' => 'appearance', 'title' => __( 'Appearance' ), 'href' => admin_url( 'themes.php' ) ) ); if ( !current_user_can( 'edit_theme_options' ) ) return; if ( current_user_can( 'switch_themes' ) ) $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'themes', 'title' => __( 'Themes' ), 'href' => admin_url( 'themes.php' ) ) ); if ( current_theme_supports( 'widgets' ) ) $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'widgets', 'title' => __( 'Widgets' ), 'href' => admin_url( 'widgets.php' ) ) ); if ( current_theme_supports( 'menus' ) || current_theme_supports( 'widgets' ) ) $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'menus', 'title' => __( 'Menus' ), 'href' => admin_url( 'nav-menus.php' ) ) ); if ( current_theme_supports( 'custom-background' ) ) $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'background', 'title' => __( 'Background' ), 'href' => admin_url( 'themes.php?page=custom-background' ) ) ); if ( current_theme_supports( 'custom-header' ) ) $wp_admin_bar->add_menu( array( 'parent' => 'appearance', 'id' => 'header', 'title' => __( 'Header' ), 'href' => admin_url( 'themes.php?page=custom-header' ) ) ); } /** * Provide an update link if theme/plugin/core updates are available */ function bp_admin_bar_updates_menu() { global $wp_admin_bar; if ( !current_user_can( 'install_plugins' ) ) return; $plugin_update_count = $theme_update_count = $wordpress_update_count = 0; $update_plugins = get_site_transient( 'update_plugins' ); if ( !empty( $update_plugins->response ) ) $plugin_update_count = count( $update_plugins->response ); $update_themes = get_site_transient( 'update_themes' ); if ( !empty( $update_themes->response ) ) $theme_update_count = count( $update_themes->response ); /* @todo get_core_updates() is only available on admin page loads $update_wordpress = get_core_updates( array('dismissed' => false) ); if ( !empty($update_wordpress) && !in_array( $update_wordpress[0]->response, array('development', 'latest') ) ) $wordpress_update_count = 1; */ $update_count = $plugin_update_count + $theme_update_count + $wordpress_update_count; if ( !$update_count ) return; $update_title = array( ); if ( !empty( $wordpress_update_count ) ) $update_title[] = sprintf( __( '%d WordPress Update' ), $wordpress_update_count ); if ( $plugin_update_count ) $update_title[] = sprintf( _n( '%d Plugin Update', '%d Plugin Updates', $plugin_update_count ), $plugin_update_count ); if ( $theme_update_count ) $update_title[] = sprintf( _n( '%d Theme Update', '%d Theme Updates', $theme_update_count ), $theme_update_count ); $update_title = !empty( $update_title ) ? esc_attr( implode( ', ', $update_title ) ) : ''; $update_title = ""; $update_title .= sprintf( __( 'Updates %s' ), "" . number_format_i18n( $update_count ) . '' ); $update_title .= ''; $wp_admin_bar->add_menu( array( 'parent' => 'dashboard', 'id' => 'updates', 'title' => $update_title, 'href' => network_admin_url( 'update-core.php' ) ) ); } /** * Handle the Admin Bar CSS */ function bp_core_load_admin_bar_css() { if ( !bp_use_wp_admin_bar() ) return; // Admin bar styles if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) $stylesheet = BP_PLUGIN_URL . '/bp-core/css/admin-bar.dev.css'; else $stylesheet = BP_PLUGIN_URL . '/bp-core/css/admin-bar.css'; wp_enqueue_style( 'bp-admin-bar', apply_filters( 'bp_core_admin_bar_css', $stylesheet ), array( 'admin-bar' ), '20110723' ); if ( !is_rtl() ) return; if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) $stylesheet = BP_PLUGIN_URL . '/bp-core/css/admin-bar-rtl.dev.css'; else $stylesheet = BP_PLUGIN_URL . '/bp-core/css/admin-bar-rtl.css'; wp_enqueue_style( 'bp-admin-bar-rtl', apply_filters( 'bp_core_admin_bar_rtl_css', $stylesheet ), array( 'bp-admin-bar' ), '20110723' ); } add_action( 'bp_init', 'bp_core_load_admin_bar_css' ); ?>