Manchmal ist sie doch praktisch, die kontextuelle Hilfe in WordPress (erreichbar über den Button «Hilfe» neben «Ansicht anpassen» im Dashboard oben rechts), vor allem, wenn Plugin- und Theme-Entwickler sie auch befüllen.
Auf einer Einstellungsseite geht es so
add_action('admin_menu', 'my_admin_add_page');
function my_admin_add_page() {
$my_admin_page = add_options_page(__('My Admin Page', 'map'), __('My Admin Page', 'map'), 'manage_options', 'map', 'my_admin_page');
// Adds my_help_tab when my_admin_page loads
add_action('load-'.$my_admin_page, 'my_admin_add_help_tab');
}
function my_admin_add_help_tab () {
$screen = get_current_screen();
$screen->add_help_tab( array(
'id' => $id, //unique id for the tab
'title' => $title, //unique visible title for the tab
'content' => $content, //actual help text
'callback' => $callback //optional function to callback
) );
}
Wie im Bearbeitungsbereich von Beiträgen die Hilfe zu einer benutzerdefinierten Metabox mit einer Eingabemaske für zusätzliche Datenfelder (Custom Fields / benutzerdefinierte Felder) untergebracht werden kann, zeigt wp-admin
/ edit.php
.
function add_my_custom_metabox() {
$screen = get_current_screen();
$post_type = $screen->post_type;
add_meta_box( 'my-custom-metabox', __( 'My Custom Metabox Title', 'my-plugin-textdomain' ), $function_callback, 'page', 'normal', 'high' );
if ( $post_type != 'page' ) return; // Hilfe zur Custom Metabox wird sonst global hinzugefügt
get_current_screen()->add_help_tab( array(
'id' => 'ppp-attach-form', //unique id for the tab
'title' => __( 'My Custom Metabox Title', 'my-plugin-textdomain' ), //unique visible title for the tab
'content' => sprintf('<p>%1$s</p>',__( 'My custom help instructions', 'my-plugin-textdomain' )), //actual help text
'callback' => '', //optional function to callback
'priority' => 15, // priority, default = 10
) );
}
Schreibe einen Kommentar