WC_Legacy_API::handle_rest_api_requests() public WC 2.2
Устарела с версии 2.6.0. Больше не поддерживается и может быть удалена. Рекомендуется заменить эту функцию на аналог.╳
Handle REST API requests.
{} Это метод класса: WC_Legacy_API{}
Хуков нет.
Возвращает
Null. Ничего.
Использование
$WC_Legacy_API = new WC_Legacy_API(); $WC_Legacy_API->handle_rest_api_requests();
Список изменений
С версии 2.2 | Введена. |
Устарела с | 2.6.0 |
Код WC_Legacy_API::handle_rest_api_requests() WC Legacy API::handle rest api requests WC 5.0.0
public function handle_rest_api_requests() {
global $wp;
if ( ! empty( $_GET['wc-api-version'] ) ) {
$wp->query_vars['wc-api-version'] = $_GET['wc-api-version'];
}
if ( ! empty( $_GET['wc-api-route'] ) ) {
$wp->query_vars['wc-api-route'] = $_GET['wc-api-route'];
}
// REST API request.
if ( ! empty( $wp->query_vars['wc-api-version'] ) && ! empty( $wp->query_vars['wc-api-route'] ) ) {
wc_maybe_define_constant( 'WC_API_REQUEST', true );
wc_maybe_define_constant( 'WC_API_REQUEST_VERSION', absint( $wp->query_vars['wc-api-version'] ) );
// Legacy v1 API request.
if ( 1 === WC_API_REQUEST_VERSION ) {
$this->handle_v1_rest_api_request();
} elseif ( 2 === WC_API_REQUEST_VERSION ) {
$this->handle_v2_rest_api_request();
} else {
$this->includes();
$this->server = new WC_API_Server( $wp->query_vars['wc-api-route'] );
// load API resource classes.
$this->register_resources( $this->server );
// Fire off the request.
$this->server->serve_request();
}
exit;
}
}