钩子文档

pre_comment_user_agent

💡 云策文档标注

概述

pre_comment_user_agent 是一个 WordPress 过滤器,用于在设置评论作者浏览器用户代理之前进行过滤。它允许开发者修改或处理用户代理字符串。

关键要点

  • 过滤器名称:pre_comment_user_agent
  • 参数:$comment_agent(字符串类型,表示评论作者浏览器用户代理)
  • 用途:在评论数据被设置前过滤用户代理,常用于数据清理或自定义处理
  • 相关函数:在 wp_filter_comment() 中被调用,用于过滤和清理评论数据
  • 引入版本:WordPress 1.5.0

📄 原文内容

Filters the comment author’s browser user agent before it is set.

Parameters

$comment_agentstring
The comment author’s browser user agent.

Source

$commentdata['comment_agent'] = apply_filters( 'pre_comment_user_agent', ( isset( $commentdata['comment_agent'] ) ? $commentdata['comment_agent'] : '' ) );

Changelog

Version Description
1.5.0 Introduced.