钩子文档

{$page_hook}

💡 云策文档标注

概述

本文档介绍了 WordPress 中的动态 Hook $page_hook,用于调用插件屏幕的注册回调函数。它由页面类型、分隔符和插件基本名称组成,形成如 'settings_page_pluginbasename' 的 Hook 名称。

关键要点

  • $page_hook 是一个动态 Hook,用于触发插件页面的回调函数。
  • Hook 名称由三部分构成:页面类型(如 'settings' 或 'toplevel')、分隔符 '_page_' 和插件基本名称(不含文件扩展名)。
  • 示例 Hook 名称:'settings_page_pluginbasename'。
  • 相关函数:get_plugin_page_hook()。
  • 源代码:do_action( $page_hook );。
  • 引入版本:WordPress 1.5.0。

📄 原文内容

Used to call the registered callback for a plugin screen.

Description

This hook uses a dynamic hook name, $page_hook, which refers to a mixture of plugin page information including:

  1. The page type. If the plugin page is registered as a submenu page, such as for Settings, the page type would be ‘settings’. Otherwise the type is ‘toplevel’.
  2. A separator of ‘_page_’.
  3. The plugin basename minus the file extension.

Together, the three parts form the $page_hook. Citing the example above, the hook name used would be ‘settings_page_pluginbasename’.

See also

Source

do_action( $page_hook );

Changelog

Version Description
1.5.0 Introduced.