WPSEO_Statistics_Service::set_statistic_items_for_user()privateYoast 1.0

Set the statistics transient cache for a specific user.

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

Хуков нет.

Возвращает

Массив. The statistics transient for the user.

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

// private - только в коде основоного (родительского) класса
$result = $this->set_statistic_items_for_user( $transient, $user );
$transient(массив) (обязательный)
The current stored transient with the cached data.
$user(int) (обязательный)
The user's ID to assign the retrieved values to.

Код WPSEO_Statistics_Service::set_statistic_items_for_user() Yoast 24.0

private function set_statistic_items_for_user( $transient, $user ) {
	$scores   = $this->get_seo_scores_with_post_count();
	$division = $this->get_seo_score_division( $scores );

	$transient[ $user ] = [
		// Use array_values because array_filter may return non-zero indexed arrays.
		'scores'   => array_values( array_filter( $scores, [ $this, 'filter_items' ] ) ),
		'division' => $division,
	];

	set_transient( self::CACHE_TRANSIENT_KEY, $transient, DAY_IN_SECONDS );

	return $transient[ $user ];
}