函数文档

current_action()

💡 云策文档标注

概述

current_action() 函数用于获取当前正在执行的动作钩子的名称。它本质上是 current_filter() 的别名,返回字符串或 false。

关键要点

  • 函数返回当前动作钩子的名称(字符串),若无动作运行则返回 false。
  • 内部实现直接调用 current_filter(),表明动作和过滤器钩子在底层机制上类似。
  • 自 WordPress 3.9.0 版本引入,相关函数包括 current_filter()。
  • 在多个核心功能中被使用,如注册块模式、切换主题等。

📄 原文内容

Retrieves the name of the current action hook.

Return

string|false Hook name of the current action, false if no action is running.

Source

function current_action() {
	return current_filter();
}

Changelog

Version Description
3.9.0 Introduced.