I have working code which adds a help tab to all screens in the admin which already have help options or a help screen – however, screens which don’t have contextual help – such as the plugin I writing, also don’t recognize the add_action call – how can I ensure that the help_tab appears on each and every screen in the admin?
Some simple code – but it’s more or less exactly like in the Codex.
I add the action in the class __construct
// add help tab to admin UI ##
add_action( "load-{$GLOBALS['pagenow']}", array( $this, 'add_help_tab' ), 20 );
This calls a method in the class “add_help_tab”:
public function add_help_tab() {
foreach ( $this->help_tabs as $id => $data ) {
get_current_screen()->add_help_tab(
array(
'id' => $id
,'title' => __( $data['title'], 'q_support' )
// Use the content only if you want to add something
// static on every help tab. Example: Another title inside the tab
,'callback' => array( $this, 'callback_function' )
)
);
}
}
Which in turn calls the callback method “callback_function” – this all works as expected, except on screens without pre-existing help tabs – is there a way I can ensure each and every page includes the help tab feature?
This is how you can add help tabs to all admin pages—no matter if there already are any, or not:
In your OOP setting this should look something like the following:
in_admin_header
is pretty much the last action hook before the screen meta (and so the help) is being rendered.So, what do you get from this?