钩子文档

rest_comment_trashable

💡 云策文档标注

概述

rest_comment_trashable 是一个 WordPress 过滤器,用于控制是否可以通过 REST API 将评论移至回收站。它允许开发者基于评论对象动态启用或禁用回收站功能。

关键要点

  • 过滤器名称:rest_comment_trashable
  • 用途:过滤评论是否支持通过 REST API 移至回收站
  • 参数:$supports_trash(布尔值,表示评论是否支持回收站),$comment(WP_Comment 对象,被考虑的评论)
  • 返回值:返回 false 可禁用评论的回收站支持
  • 相关函数:在 WP_REST_Comments_Controller::delete_item() 中使用
  • 引入版本:WordPress 4.7.0

代码示例

$supports_trash = apply_filters( 'rest_comment_trashable', ( EMPTY_TRASH_DAYS > 0 ), $comment );

📄 原文内容

Filters whether a comment can be trashed via the REST API.

Description

Return false to disable trash support for the comment.

Parameters

$supports_trashbool
Whether the comment supports trashing.
$commentWP_Comment
The comment object being considered for trashing support.

Source

$supports_trash = apply_filters( 'rest_comment_trashable', ( EMPTY_TRASH_DAYS > 0 ), $comment );

Changelog

Version Description
4.7.0 Introduced.