WC_API_Server::__construct()
Setup class and set request/response handler
Метод класса: WC_API_Server{}
Хуки из метода
Возвращает
null
. Ничего.
Использование
$WC_API_Server = new WC_API_Server(); $WC_API_Server->__construct( $path );
- $path (обязательный)
- -
Список изменений
С версии 2.1 | Введена. |
Код WC_API_Server::__construct() WC API Server:: construct WC 7.7.2
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']; } // determine type of request/response and load handler, JSON by default if ( $this->is_json_request() ) { $handler_class = 'WC_API_JSON_Handler'; } elseif ( $this->is_xml_request() ) { $handler_class = 'WC_API_XML_Handler'; } else { $handler_class = apply_filters( 'woocommerce_api_default_response_handler', 'WC_API_JSON_Handler', $this->path, $this ); } $this->handler = new $handler_class(); }