钩子文档

contextual_help

💡 云策文档标注

概述

contextual_help 是一个已弃用的过滤器,用于过滤旧版上下文帮助文本。自 WordPress 3.3.0 起,建议使用 get_current_screen()->add_help_tab() 或 get_current_screen()->remove_help_tab() 替代。

关键要点

  • 过滤器名称:contextual_help
  • 参数:$old_help(帮助文本)、$screen_id(屏幕ID)、$screen(WP_Screen 实例)
  • 弃用版本:3.3.0,替代方法为 get_current_screen()->add_help_tab() 或 get_current_screen()->remove_help_tab()
  • 引入版本:2.7.0
  • 相关函数:WP_Screen::render_screen_meta() 用于渲染屏幕帮助部分

代码示例

$old_help = apply_filters_deprecated(
    'contextual_help',
    array( $old_help, $this->id, $this ),
    '3.3.0',
    'get_current_screen()->add_help_tab(), get_current_screen()->remove_help_tab()'
);

注意事项

由于此过滤器已弃用,开发者应避免在新代码中使用,并迁移到推荐的替代方法,以确保兼容性和最佳实践。


📄 原文内容

Filters the legacy contextual help text.

Parameters

$old_helpstring
Help text that appears on the screen.
$screen_idstring
Screen ID.
$screenWP_Screen
Current WP_Screen instance.

Source

$old_help = apply_filters_deprecated(
	'contextual_help',
	array( $old_help, $this->id, $this ),
	'3.3.0',
	'get_current_screen()->add_help_tab(), get_current_screen()->remove_help_tab()'
);

Changelog

Version Description
3.3.0 Deprecated. Use get_current_screen()->add_help_tab() or get_current_screen()->remove_help_tab() instead.
2.7.0 Introduced.