WordPress at Your Fingertips
function is not described

WC_REST_Report_Reviews_Totals_Controller::get_reports() protected WC 3.5.0

Get reports list.

{} It's a method of the class: WC_REST_Report_Reviews_Totals_Controller{}

No Hooks.

Return

Array.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_reports();

Changelog

Since 3.5.0 Introduced.

Code of WC_REST_Report_Reviews_Totals_Controller::get_reports() WC 5.5.2

<?php
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;
}