I will be needing to customize the WP admin default help contents to be tailored specifically to a client in navigating his custom dashboard
What are the hooks and sample codes to use in restructuring its menu and the contents?
Files to look at:
wp-admin/includes/wp-current-screen.php
and wp-admin/admin-header.php
If we take a look at admin-header.php
we can see that $current_screen->render_screen_meta();
is the one responsible for rendering the contextual help on screens. It gets the global $current_screen
which is set via WP_Screen
class.
It has methods like get_help_tabs
,get_help_tab
,add_help_tab
,remove_help_tab
,remove_help_tabs
, set_help_sidebar
which sets and removes the tabs we see. Check the following code for sample.
/*
We can hook into admin_head-{$page_hook}. admin_head fires after the
default contextual help tabs have been added.
*/
add_action('admin_head-index.php', 'wpse_226724_add_help_tab');
function wpse_226724_add_help_tab () {
$screen = get_current_screen();
//checking whether we are on dashboard main page or not
if ( $screen->id != 'dashboard' )
return;
//You can remove all default tabs using this
//$screen->remove_help_tabs();
//Adding tab with an id overview it gets replaced if tab is already available with same id
$screen->add_help_tab( array(
'id' => 'overview',
'title' => __('WPSE'),
'content' => '<p>'
. __( 'Welcome to the WPSE community. Get a taste of WordPress!', 'text_domain' )
. '</p>',
) );
}
We can use get_help_tabs
to re-order the tabs. Default tabs available on main dashboard page (wp-admin/index.php
) are:
overview
help-navigation
help-layout
help-content
And one sidebar help