WordPress at Your Fingertips
function is not described

WC_API_Resource::__construct() public WC 2.1

Setup class

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

No Hooks.

Return

null. Nothing.

Usage

$WC_API_Resource = new WC_API_Resource();
$WC_API_Resource->__construct( $server );
$server(WC_API_Server) (required)
-

Changelog

Since 2.1 Introduced.

Code of WC_API_Resource::__construct() WC 5.7.1

public function __construct( WC_API_Server $server ) {

	$this->server = $server;

	// automatically register routes for sub-classes
	add_filter( 'woocommerce_api_endpoints', array( $this, 'register_routes' ) );

	// remove fields from responses when requests specify certain fields
	// note these are hooked at a later priority so data added via filters (e.g. customer data to the order response)
	// still has the fields filtered properly
	foreach ( array( 'order', 'coupon', 'customer', 'product', 'report' ) as $resource ) {

		add_filter( "woocommerce_api_{$resource}_response", array( $this, 'maybe_add_meta' ), 15, 2 );
		add_filter( "woocommerce_api_{$resource}_response", array( $this, 'filter_response_fields' ), 20, 3 );
	}
}