How to add a help tab to all admin pages – including plugin pages

Question

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?

--------------------------------------------------

>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="https://www.wptricks.com/question/how-to-add-a-help-tab-to-all-admin-pages-including-plugin-pages/">

How to add a help tab to all admin pages - including plugin pages</a>
0
, , Q Studio 2 months 0 Answers 78 views 0

Leave an answer