钩子文档

comments_open

💡 云策文档标注

概述

comments_open 是一个 WordPress 过滤器,用于控制当前文章是否允许评论。它允许开发者动态修改评论开放状态。

关键要点

  • 过滤器名称:comments_open
  • 参数:$comments_open(布尔值,表示当前评论开放状态)和 $post_id(整数,文章 ID)
  • 源调用:apply_filters('comments_open', $comments_open, $post_id)
  • 相关函数:comments_open() 用于确定评论是否开放
  • 引入版本:WordPress 2.5.0

📄 原文内容

Filters whether the current post is open for comments.

Parameters

$comments_openbool
Whether the current post is open for comments.
$post_idint
The post ID.

Source

return apply_filters( 'comments_open', $comments_open, $post_id );

Changelog

Version Description
2.5.0 Introduced.