WC_REST_Report_Reviews_Totals_Controller::get_reports()
Get reports list.
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. |
WC_REST_Report_Reviews_Totals_Controller::get_reports() WC REST Report Reviews Totals Controller::get reports code WC 9.7.1
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; }