Using the new WP_Screen
class makes it pretty easy to add help text to a screen.
<?php
add_action( "load-{$somepage}", 'wpse_load_reading' );
function wpse_load_reading()
{
get_current_screen()->add_help_tab( array(
'id' => 'my-help-tab',
'title' => __( 'My Title' ),
'content' => __( 'Help Content' )
) );
}
This is great for custom pages. But when adding a help tab to an existing screen, let's say options-reading.php
, some weirdness happens.
The load-options-reading.php
hook fires before the built in WP page adds its own help tabs. In other words, adding a help tab to an existing screen bumps all the built in help tabs to the bottom of the of list.
Here's some code, if you'd like to try this out:
<?php
add_action( "load-options-reading.php", 'wpse_load_reading2' );
function wpse_load_reading2()
{
get_current_screen()->add_help_tab( array(
'id' => 'my-help-tab',
'title' => __( 'My Title' ),
'content' => __( 'Why is this tab above the built in tab?' )
) );
}
Is there any way to reorder the help tabs on a screen?
EDIT:
Found a way around this. The default help tabs are added before the admin-header.php
file is included.
So you can hook into load-{$built_in_page}
, and from there hook a function admin_head
which takes care of setting up your help tabs.
<?php
add_action( 'load-options-reading.php', 'wpse45210_load' );
function wpse45210_load()
{
add_action( 'admin_head', 'wpse45210_add_help' );
}
function wpse45210_add_help()
{
get_current_screen()->add_help_tab( array(
'id' => 'my-help-tab',
'title' => __( 'My Title' ),
'content' => __( 'This tab is below the built in tab.' )
) );
}
Seems kind of like a hack. Is there a better way?