bp_button_<component>_<id>

Filters the button based on class parameters.

Description

apply_filters( 'bp_button_<component>_<id>', (string) $this_contents, (BP_Button) $instance, (string) $before, (string) $after, (array) $r ); 

This filter is a dynamic filter based on component and component ID and allows button to be manipulated externally.

Parameters (5)

0. $this_contents (string)
HTML being used for the button.
1. $instance (BP_Button)
Current BP_Button instance.
2. $before (string)
HTML appended before the actual button.
3. $after (string)
HTML appended after the actual button.
4. $r (array)
Parsed button arguments.

Usage

To run the hook, copy the example below.
  1. $this_contents = apply_filters( 'bp_button_{$component}_{$id}', $this_contents, $instance, $before, $after, $r ); 
  2.  
  3. if ( !empty( $this_contents ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the bp_button_<component>_<id> callback 
  2. function filter_bp_button_component_id( $this_contents, $instance, $before, $after, $r ) { 
  3. // make filter magic happen here... 
  4. return $this_contents
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( "bp_button_{$component}_{$id}", 'filter_bp_button_component_id', 10, 5 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( "bp_button_{$component}_{$id}", 'filter_bp_button_component_id', 10, 5 ); 

Defined (1)

The filter is defined in the following location(s).

/bp-core/classes/class-bp-button.php  
  1. $this->contents = apply_filters( 'bp_button_' . $this->component . '_' . $this->id, $this->contents, $this, $before, $after, $r );