WPSEO_Statistics_Service::get_statistics()publicYoast 1.0

Fetches statistics by REST request.

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

Хуков нет.

Возвращает

WP_REST_Response. The response object.

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

$WPSEO_Statistics_Service = new WPSEO_Statistics_Service();
$WPSEO_Statistics_Service->get_statistics();

Код WPSEO_Statistics_Service::get_statistics() Yoast 22.4

public function get_statistics() {
	// Switch to the user locale with fallback to the site locale.
	switch_to_locale( get_user_locale() );

	$this->labels = $this->labels();
	$statistics   = $this->statistic_items();

	$data = [
		'header'     => $this->get_header_from_statistics( $statistics ),
		'seo_scores' => $statistics['scores'],
	];

	return new WP_REST_Response( $data );
}