Simon Pollard
Web developer
Using WordPress help text
Full Time Web Developer at
@smp303
https://slides.com/simonp303
@smp303
In wp-admin in the top right
It is there for every screen
@smp303
Defaults to the standard WordPress help
Tabs on left change content
@smp303
No need for user guides
Help directly relates to the current screen
Easily display short tags etc
@smp303
function pages_help() {
global $post_ID;
$screen = get_current_screen();
if( isset($_GET['post_type']) ) $post_type = $_GET['post_type'];
else $post_type = get_post_type( $post_ID );
if( $post_type == 'page' ) :
$content = '<h3>Title</h3>';
$content .= '<p>Some text can go in here</p>';
$screen->add_help_tab( array(
'id' => 'help_tab_id', // unique id for the tab
'title' => 'Tab Name', // unique visible title for the tab
'content' => $content //actual help text
));
endif;
}
add_action('admin_head', 'pages_help');
@smp303
function pages_help() {
}
add_action('admin_head', 'pages_help');
Create a function to handle our help text
Hook this function into the "admin_head" function
This makes sure our help text is displayed
Create our function
@smp303
global $post_ID;
$screen = get_current_screen();
if( isset($_GET['post_type']) ) $post_type = $_GET['post_type'];
else $post_type = get_post_type( $post_ID );
if( $post_type == 'page' ) :
endif;
Find out what screen we are on
Get the post type
If the conditions are correct - show our text
Display the help in the correct place
@smp303
$content = '<h3>Title</h3>';
$content .= '<p>Some text can go in here</p>';
$screen->add_help_tab( array(
'id' => 'help_tab_id', // unique id for the tab
'title' => 'Tab Name', // unique visible title for the tab
'content' => $content //actual help text
));
Create some content
Call function (on the current screen) to show tab
Fill in all the attributes
Adding a help tab
@smp303
aka Things will probably break
@smp303
These slides and more from me...
https://slides.com/simonp303
WordPress Codex
https://codex.wordpress.org/Class_Reference/WP_Screen/add_help_tab
By Simon Pollard
Using WordPress help text