Skip to:

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#6848 closed defect (bug) (fixed)

Mis-use of contextual_help action causes issues with other plugins

Reported by: garrett-eclipse's profile garrett-eclipse Owned by: djpaul's profile DJPaul
Milestone: 2.6 Priority: high
Severity: normal Version: 2.4.0
Component: Settings Keywords:



I ran into an issue with Buddypress not cooperating with other plugins that also use the contextual_help action hook.

For instance the Wordpress Better Emails plugin ( uses the contextual_help action hook to set the contents of the Overview help tab. This information is lost once the bp_core_add_contextual_help_content function that's tied into the contextual_help action hook is run as $contextual_help string isn't being passed through and returned by the function losing all of it's contents.

To quickly resolve the implementation can be updated as follows;

  1. Update the add_action call to provide the priority and accepted_args;
    add_action( 'contextual_help', 'bp_core_add_contextual_help', 10, 3 );
  2. Update the bp_core_add_contextual_help function to accept all of the parameters;
    function bp_core_add_contextual_help( $contextual_help, $screen_id, $screen ) {
  3. Return the $contextual_help string at the end of the bp_core_add_contextual_help function;
    return $contextual_help;

This will ensure any plugins or custom functions that set the contextual_help string used in the default Overview help tab aren't overridden. If the goal is to drop the Overview tab on Buddypress components then the switch statement can be updated so it returns an empty string in all cases except default which would catch non-Buddypress screens.

Also while investigating it came to my attention that this approach using the contextual_help action hook was deprecated in Wordpress 3.3 even though it will still work.

Hope that all makes sense,
P.S. Buddypress Trac only has up to Version 2.4.0 listed but I do have 2.4.3 installed.

Change History (5)

#1 @DJPaul
8 years ago

  • Milestone changed from Awaiting Review to 2.6
  • Priority changed from normal to high

Crap, contextual_help is a filter, not an action.

This ticket was mentioned in Slack in #buddypress by djpaul. View the logs.

8 years ago

#3 @DJPaul
8 years ago

  • Owner set to DJPaul
  • Status changed from new to assigned

#4 @djpaul
8 years ago

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

In 10751:

Core: correctly add contextual help for our main admin screens.

We were mis-using the contextual_help "action" (it's actually a
filter!), so PHP was returning a void/null value, breaking other
plugins that tried to add help text through this filter.

I've hooked the function to the load- action for the relevant admin
screens as a quick fix.

Fixes #6848

#5 @garrett-eclipse
8 years ago

Thanks @djpaul, seems like a reasonable approach.

Note: See TracTickets for help on using tickets.