WC_WCCOM_Site::get_authorization_header
Get the authorization header.
On certain systems and configurations, the Authorization header will be stripped out by the server or PHP. Typically this is then used to generate PHP_AUTH_USER/PHP_AUTH_PASS but not passed on. We use getallheaders here to try and grab it out instead.
Метод класса: WC_WCCOM_Site{}
Хуков нет.
Возвращает
string. Authorization header if set.
Использование
$result = WC_WCCOM_Site::get_authorization_header();
Список изменений
| С версии 3.7.0 | Введена. |
Код WC_WCCOM_Site::get_authorization_header() WC WCCOM Site::get authorization header WC 11.2.2
protected static function get_authorization_header() {
if ( ! empty( $_SERVER['HTTP_AUTHORIZATION'] ) ) {
return wp_unslash( $_SERVER['HTTP_AUTHORIZATION'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
}
if ( function_exists( 'getallheaders' ) ) {
$headers = getallheaders();
// Check for the authorization header case-insensitively.
foreach ( $headers as $key => $value ) {
if ( 'authorization' === strtolower( $key ) ) {
return $value;
}
}
}
return '';
}