WordPress at a glance
function is not described

WP_Comment::get_instance() public WP 4.4.0

Retrieves a WP_Comment instance.

{} It's a method of the class: WP_Comment{}

No Hooks.

Return

WP_Comment/false. Comment object, otherwise false.

Usage

$result = WP_Comment::get_instance( $id );
$id(int) (required)
Comment ID.

Notes

  • Global. wpdb. $wpdb WordPress database abstraction object.

Changelog

Since 4.4.0 Introduced.

Code of WP_Comment::get_instance() WP 5.5.3

<?php
public static function get_instance( $id ) {
	global $wpdb;

	$comment_id = (int) $id;
	if ( ! $comment_id ) {
		return false;
	}

	$_comment = wp_cache_get( $comment_id, 'comment' );

	if ( ! $_comment ) {
		$_comment = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_ID = %d LIMIT 1", $comment_id ) );

		if ( ! $_comment ) {
			return false;
		}

		wp_cache_add( $_comment->comment_ID, $_comment, 'comment' );
	}

	return new WP_Comment( $_comment );
}