Skip to:
Content

BuddyPress.org

Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#6848 closed defect (bug) (fixed)

Mis-use of contextual_help action causes issues with other plugins

Reported by: garrett-eclipse Owned by: DJPaul
Milestone: 2.6 Priority: high
Severity: normal Version: 2.4.0
Component: Settings Keywords:
Cc:

Description

Hello,

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 (https://wordpress.org/plugins/wp-better-emails/) 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;
    <?php
    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;
    <?php
    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;
    <?php
    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.
https://codex.wordpress.org/Adding_Contextual_Help_to_Administration_Menus

Hope that all makes sense,
Cheers
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
5 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.


5 years ago

#3 @DJPaul
4 years ago

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

#4 @djpaul
4 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
4 years ago

Thanks @djpaul, seems like a reasonable approach.

Note: See TracTickets for help on using tickets.