API / Minn\Blocks\Dynamic\Theme / Comments

Comments final readonly class

Minn\Blocks\Dynamic\Theme\Comments · public/minn/src/Minn/Blocks/Dynamic/Theme/Comments.php · 305 lines

comments, comments-title, comment-template, the comment-* blocks, the comment form, and the legacy post-comments.

Constants and properties

privateDEPTH = 'comment_depth'

The global the comment loop's depth is kept in, as get_comment_class and the reply link read it.

privatereadonly Minn\Content\Site $site

Promoted from the constructor.

privatereadonly Minn\Front\Permalinks $permalinks

Promoted from the constructor.

privatereadonly Minn\Content\Posts $posts

Promoted from the constructor.

privatereadonly Minn\Content\Users $users

Promoted from the constructor.

Public

new__construct(Minn\Content\Site $site, Minn\Front\Permalinks $permalinks, Minn\Content\Posts $posts, Minn\Content\Users $users)#
methodregister(Minn\Blocks\Renderer $renderer): void#

Registers this family's blocks with the renderer.

staticquery(array $vars): Minn\Objects\CommentsQuery#

The comment query a comment template's vars ask for, run once a request: the template and its pagination links ask for the same one, and the reference answers the repeat from its cache. A comment write drops it (RowCache).

$varsarray<string, mixed>

Internals 16

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatecomments(Minn\Blocks\Block $block, Minn\Blocks\Renderer $renderer): string#

Nothing at all when the post has no comments and takes none.

privatelegacy(Minn\Blocks\Block $block, Minn\Blocks\Renderer $renderer): string#

The comments as a classic theme prints them (comments_template(), the theme's comments.php or core's own), in the block's wrapper: the legacy post-comments block (Twenty Twenty-Two's single template), and a comments block saved before it held inner blocks (legacy). A legacy comments block keeps post-comments' class ahead of its own. Nothing when the post takes no comments and has none; a protected post gets the template's own notice.

privatetitle(Minn\Blocks\Block $block, Minn\Blocks\Renderer $renderer): string#
privatetemplate(Minn\Blocks\Block $block, Minn\Blocks\Renderer $renderer): string#
privaterecords(array $comments, bool $threaded): array#

The query's comments as records, each followed by its replies when they are threaded; unthreaded, every one stands at the top level.

$commentslist<\WP_Comment>
@return list<CommentRecord>
privatecount(Minn\Content\PostRecord $post): int#

How many comments a post shows: its count, as get_comments_number filters it.

privatelist(array $all, int $parent, int $depth, Minn\Blocks\Block $block, Minn\Blocks\Renderer $renderer): string#
$alllist<array>
privateavatar(Minn\Blocks\Block $block, Minn\Blocks\Renderer $renderer): string#

The comment author's avatar in a comment loop; elsewhere the post author's, linked to their posts when asked.

privateauthorAvatar(Minn\Blocks\Block $block, Minn\Blocks\Renderer $renderer, int $size): string#
privatedate(Minn\Blocks\Block $block, Minn\Blocks\Renderer $renderer): string#

When the comment was written, in the format asked for (else the site's), linked to the comment unless isLink is off.

privatecommentPost(Minn\Content\CommentRecord $comment, Minn\Blocks\Renderer $renderer): ?Minn\Content\PostRecord#

The post a comment belongs to: the loop's, or looked up when the comment came by itself (a comment block's render callback).

privateauthorName(Minn\Blocks\Block $block, Minn\Blocks\Renderer $renderer): string#
privatecontent(Minn\Blocks\Block $block, Minn\Blocks\Renderer $renderer): string#
privatereplyLink(Minn\Blocks\Block $block, Minn\Blocks\Renderer $renderer): string#
privateform(Minn\Blocks\Block $block, Minn\Blocks\Renderer $renderer): string#
privatecommentForm(int $postId, Minn\Blocks\Block $block): string#

The form is comment_form()'s, as the reference's block renders it: the block theme's button in its defaults, the block's classes on the respond wrapper, and every comment_form hook a plugin uses to add its fields (a spam plugin's hidden check, a consent box) fired on the way.