modulesfeature-comments.php

Functions

get_comment_filename()

get_comment_filename(string  $pagename) : string

Given a page name, returns the absolute file path in which that page's comments are stored.

Parameters

string $pagename

The name pf the page to fetch the comments filename for.

Returns

string —

The path to the file that the

generate_comment_id()

generate_comment_id() : string

Generates a new random comment id.

Returns

string —

A new random comment id.

find_comment()

find_comment(array  $comment_data, string  $comment_id) : object

Finds the comment with specified id by way of an almost-breadth-first search.

Parameters

array $comment_data

The comment data to search.

string $comment_id

The id of the comment to find.

Returns

object —

The comment data with the specified id, or false if it wasn't found.

delete_comment()

delete_comment(array  $comment_data, string  $target_id) : boolean

Deletes the first comment found with the specified id.

Parameters

array $comment_data

An array of threaded comments to delete the comment from.

string $target_id

The id of the comment to delete.

Returns

boolean —

Whether the comment was found and deleted or not.

fetch_comment_thread()

fetch_comment_thread(array  $comment_data, string  $comment_id) : array<mixed,object>

Fetches all the parent comments of the specified comment id, including the comment itself at the end.

Useful for figuring out who needs notifying when a new comment is posted.

Parameters

array $comment_data

The comment data to search.

string $comment_id

The comment id to fetch the thread for.

Returns

array<mixed,object> —

A list of the comments in the thread, with the deepest one at the end.

render_comments()

render_comments(array<mixed,object>  $comments_data, integer  $depth) : string

Renders a given comments tree to html.

Parameters

array<mixed,object> $comments_data

The comments tree to render.

integer $depth

For internal use only. Specifies the depth at which the comments are being rendered.

Returns

string —

The given comments tree as html.