WP_Metadata_Lazyloader::lazyload_meta_callback()publicWP 6.3.0

Lazy-loads meta for queued objects.

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.

Метод класса: WP_Metadata_Lazyloader{}

Хуков нет.

Возвращает

Разное. In order not to short-circuit get_metadata(). Generally, this is null, but it could be another value if filtered by a plugin.

Использование

$WP_Metadata_Lazyloader = new WP_Metadata_Lazyloader();
$WP_Metadata_Lazyloader->lazyload_meta_callback( $check, $object_id, $meta_key, $single, $meta_type );
$check(разное) (обязательный)
The $check param passed from the 'get_*_metadata' hook.
$object_id(int) (обязательный)
ID of the object metadata is for.
$meta_key(строка) (обязательный)
Unused.
$single(true|false) (обязательный)
Unused.
$meta_type(строка) (обязательный)
Type of object metadata is for. Accepts 'post', 'comment', 'term', 'user', or any other object type with an associated meta table.

Список изменений

С версии 6.3.0 Введена.

Код WP_Metadata_Lazyloader::lazyload_meta_callback() WP 6.7.1

public function lazyload_meta_callback( $check, $object_id, $meta_key, $single, $meta_type ) {
	if ( empty( $this->pending_objects[ $meta_type ] ) ) {
		return $check;
	}

	$object_ids = array_keys( $this->pending_objects[ $meta_type ] );
	if ( $object_id && ! in_array( $object_id, $object_ids, true ) ) {
		$object_ids[] = $object_id;
	}

	update_meta_cache( $meta_type, $object_ids );

	// No need to run again for this set of objects.
	$this->reset_queue( $meta_type );

	return $check;
}