API / Minn\Runtime / CommentChecks

CommentChecks final class

Minn\Runtime\CommentChecks · public/minn/src/Minn/Runtime/CommentChecks.php · 296 lines

What WordPress checks of a comment before and after it is stored: the lengths the table allows its fields, each field through its pre_comment_ filter, the status a stored comment has in words, and whether a new post of a type starts open to comments or pings.

Public

staticfieldMaxLengths(): mixed#

How long each comment form field may be (wp_get_comment_fields_max_lengths), as the table allows, through wp_get_comment_fields_max_lengths.

@return array<string, int>
staticmaxLengths(mixed $data): mixed#

Whether a comment fits its columns (wp_check_comment_data_max_lengths): true, or the error naming the first field too long.

staticfilter(mixed $data): array#

Each field through its pre_comment_ filter (wp_filter_comment), in the reference's order (the user first, the email last), marked filtered.

@return array<string, mixed>
staticstatus(mixed $commentId): mixed#

A comment's status (wp_get_comment_status): approved, unapproved, spam or trash; false for an unknown comment or status.

staticdefaultStatus(mixed $type = 'post', mixed $commentType = 'comment'): mixed#

Whether a new post of a type starts open (get_default_comment_status): a page starts closed; another type follows the site's default when it supports comments (or trackbacks, for pings).

staticpasses(mixed $author, mixed $email, mixed $url, mixed $comment, mixed $userIp, mixed $userAgent, mixed $commentType): bool#

Whether a comment needs no moderation (check_comment): never while moderation is on; the links counted in the comment as comment_text shows it (comment_max_links_url may recount) against comment_max_links; the moderation words; and, when asked, an earlier approved comment from the same author (a pingback from one of the site's own posts, as wp_auto_approve_ping decides; a trackback never).

staticdisallowed(mixed $author, mixed $email, mixed $url, mixed $comment, mixed $userIp, mixed $userAgent): bool#

Whether a line of disallowed_keys appears in the comment's fields (wp_check_comment_disallowed_list): a word match, or an address's start; the comment read without its tags and entities too.

staticapproval(mixed $data): mixed#

A comment's approval as its data asks (wp_check_comment_data): the post's author and a moderator are approved; anyone else's comment passes check_comment or is held, and the disallowed words send it to the trash (spam with the trash off); pre_comment_approved has the last word. The data may be slashed.

staticallow(mixed $commentdata, mixed $wpError = false): mixed#

1, 0, "spam" or "trash" for a comment that may be stored (wp_allow_comment), in the reference's order: a duplicate, which duplicate_comment_id may name or clear, refuses with 409; check_comment_flood and wp_is_comment_flood refuse a flood with 429; then the approval. The error when asked for one, else the stop page, for a refusal.

staticcreate(mixed $commentdata, mixed $wpError = false): mixed#

A comment from outside stored the way the comment form stores one (wp_new_comment): preprocess_comment; the ids, user, parent, address, agent and dates filled in; wp_allow_comment; the pre_comment_ filters; the approval judged again on what they left; the comment stored; comment_post. The id, or the error when asked for one (false without).

staticcurrentCommenter(): mixed#

The commenter remembered by the comment_author_ cookies (wp_get_current_commenter), as wp_get_current_commenter leaves them.

staticunapprovedEmail(): string#

The address of the reader whose held comment the page may show (wp_get_unapproved_comment_author_email): from a held comment's link (its hash right, under ten minutes old), or else from the commenter's cookie.

Internals 3

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

privatefilledIn(array $data): array#

What wp_new_comment fills in: integer ids, the user from user_ID, a parent only when it is approved or held, the request's address and agent, the dates now, the type "comment".

$dataarray<string, mixed>
@return array<string, mixed>
privaterefused(mixed $wpError, string $code, mixed $message, int $status): mixed#

A refusal: the error when one was asked for, else the stop page with the status.

privatecomments(): Minn\Content\Comments#