要查看的文件:wp-admin/includes/wp-current-screen.php
和wp-admin/admin-header.php
如果我们看看admin-header.php
我们可以看到$current_screen->render_screen_meta();
负责在屏幕上呈现上下文帮助。它得到了全球$current_screen
通过以下方式设置WP_Screen
班
它有如下方法get_help_tabs
,get_help_tab
,add_help_tab
,remove_help_tab
,remove_help_tabs
, set_help_sidebar
设置和删除我们看到的选项卡。检查以下代码以获取示例。
/*
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>\',
) );
}
我们可以使用
get_help_tabs
重新排序选项卡。主仪表板页面上可用的默认选项卡(
wp-admin/index.php
) 是:
概述
帮助导航
帮助布局
帮助内容
和一个侧边栏帮助