WC_API_Server::__construct()publicWC 2.1

Setup class and set request/response handler

Method of the class: WC_API_Server{}

Return

null. Nothing (null).

Usage

$WC_API_Server = new WC_API_Server();
$WC_API_Server->__construct( $path );
$path (required)
-

Changelog

Since 2.1 Introduced.

WC_API_Server::__construct() code WC 8.9.0

public function __construct( $path ) {

	if ( empty( $path ) ) {
		if ( isset( $_SERVER['PATH_INFO'] ) ) {
			$path = $_SERVER['PATH_INFO'];
		} else {
			$path = '/';
		}
	}

	$this->path           = $path;
	$this->method         = $_SERVER['REQUEST_METHOD'];
	$this->params['GET']  = $_GET;
	$this->params['POST'] = $_POST;
	$this->headers        = $this->get_headers( $_SERVER );
	$this->files          = $_FILES;

	// Compatibility for clients that can't use PUT/PATCH/DELETE
	if ( isset( $_GET['_method'] ) ) {
		$this->method = strtoupper( $_GET['_method'] );
	} elseif ( isset( $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] ) ) {
		$this->method = $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'];
	}

	// load response handler
	$handler_class = apply_filters( 'woocommerce_api_default_response_handler', 'WC_API_JSON_Handler', $this->path, $this );

	$this->handler = new $handler_class();
}