Skip to:
Content

BuddyPress.org

Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#2355 closed enhancement (worksforme)

bp_core_new_nav_item doesn't allow for an array as a callback.

Reported by: brandondove's profile brandondove Owned by:
Milestone: 1.5 Priority: normal
Severity: Version:
Component: Core Keywords: bp_core_new_nav_item
Cc:

Description

When you're including this functionality in a class definition, the callback function can't be found based on just a string function. Below is the syntax BP allows for if not within a class definition:

bp_core_new_nav_item( array(
	'...' => '...',
	'screen_function' => 'show_user_ideas',
	'...' => '...'
) );
function show_user_ideas() { ... }

It seems like it should allow for the following:

class Foo {

	function Foo() {
		bp_core_new_nav_item( array(
			'...' => '...',
			'screen_function' => array( 'show_user_ideas', &$this ),
			'...' => '...'
		) );
	}

	function show_user_ideas() { ... }
}

I'm using WordPress (3.0-beta1) and BuddyPress 1.3-bleeding.

Change History (3)

#1 @DJPaul
14 years ago

  • Type changed from defect to enhancement

#2 @boonebgorges
14 years ago

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

It works if you use this kind of syntax:

class Foo {

	function Foo() {
		bp_core_new_nav_item( array(
			'...' => '...',
			'screen_function' => $this->show_user_ideas(),
			'...' => '...'
		) );
	}

	function show_user_ideas() { ... }
}

#3 @scribu
13 years ago

'screen_function' => $this->show_user_ideas() just executes the callback immediately; it doesn't pass it.

However, array( 'show_user_ideas', &$this ) is wrong too.

The correct syntax is array( &$this, 'show_user_ideas' ).

Note: See TracTickets for help on using tickets.