comments
Table of Contents
- get_comment_filename() : string
- Given a page name, returns the absolute file path in which that page's comments are stored.
- generate_comment_id() : string
- Generates a new random comment id.
- find_comment() : object
- Finds the comment with specified id by way of an almost-breadth-first search.
- delete_comment() : bool
- Deletes the first comment found with the specified id.
- fetch_comment_thread() : array<string|int, object>
- Fetches all the parent comments of the specified comment id, including the comment itself at the end.
- render_comments() : string
- Renders a given comments tree to html.
Functions
get_comment_filename()
Given a page name, returns the absolute file path in which that page's comments are stored.
get_comment_filename(string $pagename) : string
Parameters
- $pagename : string
-
The name pf the page to fetch the comments filename for.
Return values
string —The path to the file that the
generate_comment_id()
Generates a new random comment id.
generate_comment_id() : string
Return values
string —A new random comment id.
find_comment()
Finds the comment with specified id by way of an almost-breadth-first search.
find_comment(array<string|int, mixed> $comment_data, string $comment_id) : object
Parameters
- $comment_data : array<string|int, mixed>
-
The comment data to search.
- $comment_id : string
-
The id of the comment to find.
Return values
object —The comment data with the specified id, or false if it wasn't found.
delete_comment()
Deletes the first comment found with the specified id.
delete_comment(array<string|int, mixed> &$comment_data, string $target_id) : bool
Parameters
- $comment_data : array<string|int, mixed>
-
An array of threaded comments to delete the comment from.
- $target_id : string
-
The id of the comment to delete.
Return values
bool —Whether the comment was found and deleted or not.
fetch_comment_thread()
Fetches all the parent comments of the specified comment id, including the comment itself at the end.
fetch_comment_thread(array<string|int, mixed> $comment_data, string $comment_id) : array<string|int, object>
Useful for figuring out who needs notifying when a new comment is posted.
Parameters
- $comment_data : array<string|int, mixed>
-
The comment data to search.
- $comment_id : string
-
The comment id to fetch the thread for.
Return values
array<string|int, object> —A list of the comments in the thread, with the deepest one at the end.
render_comments()
Renders a given comments tree to html.
render_comments(array<string|int, object> $comments_data, int $depth) : string
Parameters
- $comments_data : array<string|int, object>
-
The comments tree to render.
- $depth : int
-
For internal use only. Specifies the depth at which the comments are being rendered.
Return values
string —The given comments tree as html.