钩子文档

wp_protected_ajax_actions

💡 云策文档标注

概述

wp_protected_ajax_actions 是一个 WordPress 过滤器,用于修改受保护的 Ajax 操作数组。该过滤器仅在处理 Ajax 请求且请求包含 'action' 属性时触发。

关键要点

  • 过滤器名称:wp_protected_ajax_actions
  • 触发条件:仅在 Ajax 请求中且请求有 'action' 属性时
  • 参数:$actions_to_protect,一个字符串数组,表示要保护的 Ajax 操作
  • 用途:用于防止 WSOD(白屏死机)等问题的 Ajax 操作保护
  • 相关函数:is_protected_ajax_action() 用于判断当前处理的 Ajax 操作是否受保护
  • 引入版本:WordPress 5.2.0

📄 原文内容

Filters the array of protected Ajax actions.

Description

This filter is only fired when doing Ajax and the Ajax request has an ‘action’ property.

Parameters

$actions_to_protectstring[]
Array of strings with Ajax actions to protect.

Source

$actions_to_protect = (array) apply_filters( 'wp_protected_ajax_actions', $actions_to_protect );

Changelog

Version Description
5.2.0 Introduced.