Automattic\WooCommerce\Admin\API\Reports\PerformanceIndicators

Controller::get_allowed_items()publicWC 1.0

Returns a list of allowed performance indicators.

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

Хуков нет.

Возвращает

Массив|WP_Error.

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

$Controller = new Controller();
$Controller->get_allowed_items( $request );
$request(WP_REST_Request) (обязательный)
Request data.

Код Controller::get_allowed_items() WC 8.7.0

public function get_allowed_items( $request ) {
	$indicator_data = $this->get_indicator_data();
	if ( is_wp_error( $indicator_data ) ) {
		return $indicator_data;
	}

	$data = array();
	foreach ( $this->allowed_stats as $stat ) {
		$pieces = $this->get_stats_parts( $stat );
		$report = $pieces[0];
		$chart  = $pieces[1];
		$data[] = (object) array(
			'stat'  => $stat,
			'chart' => $chart,
			'label' => $this->labels[ $stat ],
		);
	}

	usort( $data, array( $this, 'sort' ) );

	$objects = array();
	foreach ( $data as $item ) {
		$prepared  = $this->prepare_item_for_response( $item, $request );
		$objects[] = $this->prepare_response_for_collection( $prepared );
	}

	return $this->add_pagination_headers(
		$request,
		$objects,
		(int) count( $data ),
		1,
		1
	);
}