#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;
- Update the add_action call to provide the priority and accepted_args;
<?php add_action( 'contextual_help', 'bp_core_add_contextual_help', 10, 3 );
- 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 ) {
- 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.
Crap,
contextual_help
is a filter, not an action.