WP_Comment
- Since
- 4.4.0
- Source
wp-includes/class-wp-comment.php:60
Core class used to organize comments as instantiated objects with defined members.
Description
The @property-read fields below are not stored on the comment. They are proxied to the comment's post by WP_Comment::__get(), and are null when the comment is not attached to a post or when that post no longer exists.
Compatibility
- WordPress
- since 4.4.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Properties · 18
$comment_IDstringpublic- Comment ID.
$comment_post_IDstringpublic- ID of the post the comment is associated with.
$comment_authorstringpublic- Comment author name.
$comment_author_emailstringpublic- Comment author email address.
$comment_author_urlstringpublic- Comment author URL.
$comment_author_IPstringpublic- Comment author IP address (IPv4 format).
$comment_datestringpublic- Comment date in YYYY-MM-DD HH:MM:SS format.
$comment_date_gmtstringpublic- Comment GMT date in YYYY-MM-DD HH::MM:SS format.
$comment_contentstringpublic- Comment content.
$comment_karmastringpublic- Comment karma count.
$comment_approvedstringpublic- Comment approval status.
$comment_agentstringpublic- Comment author HTTP user agent.
$comment_typestringpublic- Comment type.
$comment_parentstringpublic- Parent comment ID.
$user_idstringpublic- Comment author ID.
$childrenarray<int,protected- Comment children.
$populated_childrenboolprotected- Whether children have been populated for this comment object.
$post_fieldsstring[]protected- Post fields.
Methods · 9
- get_instance()Retrieves a WP_Comment instance.
- __construct()Constructor.
- to_array()Converts object to array.
- get_children()Gets the children of a comment.
- add_child()Adds a child to the comment.
- get_child()Gets a child comment by ID.
- populated_children()Sets the 'populated_children' flag.
- __isset()Determines whether a non-public property is set.
- __get()Magic getter.
Source code
#[AllowDynamicProperties]final class WP_Comment { /** * Comment ID. * * A numeric string, for compatibility reasons. * * @since 4.4.0 * @var string * @phpstan-var numeric-string */ public $comment_ID; /** * ID of the post the comment is associated with. * * A numeric string, for compatibility reasons. * * @since 4.4.0 * @var string * @phpstan-var numeric-string */ public $comment_post_ID = '0'; /** * Comment author name. * * @since 4.4.0 * @var string */ public $comment_author = ''; /** * Comment author email address. * * @since 4.4.0 * @var string */ public $comment_author_email = ''; /** * Comment author URL. * * @since 4.4.0 * @var string */ public $comment_author_url = ''; /** * Comment author IP address (IPv4 format). * * @since 4.4.0 * @var string */ public $comment_author_IP = ''; /** * Comment date in YYYY-MM-DD HH:MM:SS format. * * @since 4.4.0 * @var string * @phpstan-var non-empty-string */ public $comment_date = '0000-00-00 00:00:00'; /** * Comment GMT date in YYYY-MM-DD HH::MM:SS format. * * @since 4.4.0 * @var string * @phpstan-var non-empty-string */ public $comment_date_gmt = '0000-00-00 00:00:00'; /** * Comment content. * * @since 4.4.0 * @var stringChangelog
Introduced in 4.4.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/class-wp-comment.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.