WC_REST_Report_Reviews_Totals_Controller::get_reports()protectedWC 3.5.0

Get reports list.

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

Хуков нет.

Возвращает

Массив.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->get_reports();

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

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

Код WC_REST_Report_Reviews_Totals_Controller::get_reports() WC 8.7.0

protected function get_reports() {
	$data = array();

	$query_data = array(
		'count'      => true,
		'post_type'  => 'product',
		'meta_key'   => 'rating', // WPCS: slow query ok.
		'meta_value' => '', // WPCS: slow query ok.
	);

	for ( $i = 1; $i <= 5; $i++ ) {
		$query_data['meta_value'] = $i;

		$data[] = array(
			'slug'  => 'rated_' . $i . '_out_of_5',
			/* translators: %s: average rating */
			'name'  => sprintf( __( 'Rated %s out of 5', 'woocommerce' ), $i ),
			'total' => (int) get_comments( $query_data ),
		);
	}

	return $data;
}