钩子文档

heartbeat_received

💡 云策文档标注

概述

heartbeat_received 是一个 WordPress 过滤器,用于修改 Heartbeat API 接收到的响应数据。它允许开发者在服务器端处理 AJAX 心跳请求时自定义响应内容。

关键要点

  • 这是一个过滤器 Hook,用于处理 Heartbeat API 的响应。
  • 接收三个参数:$response(响应数组)、$data($_POST 数据数组)和 $screen_id(屏幕 ID 字符串)。
  • 在 wp_ajax_heartbeat() 函数中被调用,用于 AJAX 心跳请求处理。
  • 自 WordPress 3.6.0 版本引入。

📄 原文内容

Filters the Heartbeat response received.

Parameters

$responsearray
The Heartbeat response.
$dataarray
The $_POST data sent.
$screen_idstring
The screen ID.

Source

$response = apply_filters( 'heartbeat_received', $response, $data, $screen_id );

Changelog

Version Description
3.6.0 Introduced.