WP_Metadata_Lazyloader::lazyload_comment_meta() WordPress Method

The WP_Metadata_Lazyloader::lazyload_comment_meta() method is used to lazy load comment meta data for a given comment ID. This is useful when comment meta data is not needed immediately, but can be loaded later when needed. This can help improve performance by avoiding unnecessary database queries.

WP_Metadata_Lazyloader::lazyload_comment_meta( mixed $check ) #

Lazy-loads comment meta for queued comments.


Description

This method is public so that it can be used as a filter callback. As a rule, there is no need to invoke it directly, from either inside or outside the WP_Query object.


Top ↑

Parameters

$check

(mixed)(Required)The $check param passed from the 'get_comment_metadata' hook.


Top ↑

Return

(mixed) The original value of $check, so as not to short-circuit get_comment_metadata().


Top ↑

Source

File: wp-includes/class-wp-metadata-lazyloader.php

	public function lazyload_comment_meta( $check ) {
		if ( ! empty( $this->pending_objects['comment'] ) ) {
			update_meta_cache( 'comment', array_keys( $this->pending_objects['comment'] ) );

			// No need to run again for this set of comments.
			$this->reset_queue( 'comment' );
		}

		return $check;
	}


Top ↑

Changelog

Changelog
VersionDescription
4.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.