Skip to:
Content

BuddyPress.org

Opened 15 years ago

Closed 14 years ago

#2168 closed enhancement (fixed)

Add an action hook to bp_adminbar_blogs_menu()

Reported by: travel-junkie's profile travel-junkie Owned by:
Milestone: 1.5 Priority: minor
Severity: Version:
Component: Activity Keywords:
Cc:

Description

In case we want to integrate a plugin into the blogs menu on the buddybar an action inside the list would make things far easier.

Below you find the adjusted function:

// *** "My Blogs" Menu ********
function bp_adminbar_blogs_menu() {
	global $bp;

	if ( !is_user_logged_in() || !function_exists('bp_blogs_install') )
		return false;

	if ( !$blogs = wp_cache_get( 'bp_blogs_of_user_' . $bp->loggedin_user->id . '_inc_hidden', 'bp' ) ) {
		$blogs = bp_blogs_get_blogs_for_user( $bp->loggedin_user->id, true );
		wp_cache_set( 'bp_blogs_of_user_' . $bp->loggedin_user->id . '_inc_hidden', $blogs, 'bp' );
	}

	echo '<li id="bp-adminbar-blogs-menu"><a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/my-blogs">';

	_e( 'My Blogs', 'buddypress' );

	echo '</a>';
	echo '<ul>';

	if ( is_array( $blogs['blogs'] ) && (int)$blogs['count'] ) {
		$counter = 0;
		foreach ( (array)$blogs['blogs'] as $blog ) {
			$alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
			$site_url = esc_attr( $blog->siteurl );
	
			echo '<li' . $alt . '>';
			echo '<a href="' . $site_url . '">' . esc_html( $blog->name ) . '</a>';
	
			echo '<ul>';
			echo '<li class="alt"><a href="' . $site_url . 'wp-admin/">' . __( 'Dashboard', 'buddypress' ) . '</a></li>';
			echo '<li><a href="' . $site_url . 'wp-admin/post-new.php">' . __( 'New Post', 'buddypress' ) . '</a></li>';
			echo '<li class="alt"><a href="' . $site_url . 'wp-admin/edit.php">' . __( 'Manage Posts', 'buddypress' ) . '</a></li>';
			echo '<li><a href="' . $site_url . 'wp-admin/edit-comments.php">' . __( 'Manage Comments', 'buddypress' ) . '</a></li>';
			
			do_action( 'bp_custom_blog_items', $blog );
			
			echo '</ul>';
	
			echo '</li>';
			$counter++;
		}
	}

	$alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';

	if ( bp_blog_signup_enabled() ) {
		echo '<li' . $alt . '>';
		echo '<a href="' . $bp->root_domain . '/' . $bp->blogs->slug . '/create/">' . __( 'Create a Blog!', 'buddypress' ) . '</a>';
		echo '</li>';
	}

	echo '</ul>';
	echo '</li>';
}

Change History (2)

#1 @apeatling
15 years ago

  • Component set to Activity
  • Milestone changed from 1.2.2 to 1.3

#2 @boonebgorges
14 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [3404]) Adds do_action() hook after items on the My Blogs item on the admin bar. Fixes #2168. Props travel-junkie

Note: See TracTickets for help on using tickets.