钩子文档

activate_header

💡 云策文档标注

概述

activate_header 是一个 WordPress Hook,在站点激活页面加载前触发。它主要用于多站点网络环境,定义在 wp-activate.php 文件中。

关键要点

  • 触发时机:在 Site Activation 页面加载之前执行。
  • 定义位置:位于 wp-activate.php 文件中,该文件包含主题的 header.php 但不包含 functions.php。
  • 使用限制:如果 Hook 触发的函数定义在主题的 functions.php 中,会导致致命错误;在 functions.php 中添加 Hook 函数可能无效。
  • 适用场景:仅在 WordPress 多站点网络激活时调用。
  • 版本历史:自 WordPress 3.0.0 版本引入。

📄 原文内容

Fires before the Site Activation page is loaded.

Source

do_action( 'activate_header' );

Changelog

Version Description
3.0.0 Introduced.

User Contributed Notes

  1. Skip to note 2 content

    activate_header hook is defined in wp-activate.php file which includes theme’s header.php but not the functions.php file. So it will throw fatal errors if any function or functions called on fire of this hook which are defined in theme’s functions.php. Also it’ll not work if you hook any function in functions.php. And this wp-activate.php page is only being called when WordPress multi site network is activate.