钩子文档

get_to_ping

💡 云策文档标注

概述

get_to_ping 是一个 WordPress 过滤器,用于修改待 ping 的 URL 列表。它允许开发者在 WordPress 自动 ping 之前调整 URL 数组,但回调函数不应直接执行 ping 操作。

关键要点

  • 过滤器名称:get_to_ping,用于过滤给定文章的待 ping URL 列表。
  • 参数:$to_ping,一个字符串数组,表示待 ping 的 URL。
  • 回调函数职责:仅修改 URL 数组,不应执行 ping 操作;必须返回处理后的数组以避免错误。
  • 相关函数:get_to_ping() 用于检索需要 ping 的 URL。
  • 引入版本:WordPress 2.0.0。

注意事项

回调函数必须返回一个 URL 数组,否则可能导致代码中断或插件错误。


📄 原文内容

Filters the list of URLs yet to ping for the given post.

Parameters

$to_pingstring[]
List of URLs yet to ping.

More Information

  • Callback functions applied to this filter should not ping the URLs. Instead, they may modify the array of URLs to be pinged, and WordPress will ping them automatically.
  • Note that each of the filter callback functions must return an array of URLs after it is finished processing. Otherwise, any code using the $to_ping array will break and other plugins also filtering the $to_ping array may generate errors.

Source

return apply_filters( 'get_to_ping', $to_ping );

Changelog

Version Description
2.0.0 Introduced.