WC_Legacy_API::handle_rest_api_requests()
Устарела с версии 2.6.0. Больше не поддерживается и может быть удалена. Рекомендуется заменить эту функцию на аналог.
Handle REST API requests.
Метод класса: WC_Legacy_API{}
Хуков нет.
Возвращает
null
. Ничего (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 8.7.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']; } if ( empty( $wp->query_vars['wc-api-version'] ) || empty( $wp->query_vars['wc-api-route'] ) ) { return; } // REST API request. wc_maybe_define_constant( 'WC_API_REQUEST', true ); wc_maybe_define_constant( 'WC_API_REQUEST_VERSION', absint( $wp->query_vars['wc-api-version'] ) ); $route = $wp->query_vars['wc-api-route']; $this->maybe_log_rest_api_request( $route, $_SERVER['HTTP_USER_AGENT'] ?? null ); // 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( $route ); // load API resource classes. $this->register_resources( $this->server ); // Fire off the request. $this->server->serve_request(); } exit; }