wp_is_site_protected_by_basic_auth()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
wp_is_site_protected_by_basic_auth( string $context = '' ): bool
Описание
На данный момент здесь лишь проверяется наличие учётных данных Basic Auth. Поэтому вызов этой функции с контекстом, отличным от текущего, может давать неточные результаты.
В одном из будущих выпусков эта проверка может быть сделана более надёжной.
Сейчас это используется только паролями приложений, чтобы предотвратить конфликт, поскольку они также применяют Basic Auth.
Оригинал (английский)
At the moment, this merely checks for the present of Basic Auth credentials. Therefore, calling this function with a context different from the current context may give inaccurate results.
In a future release, this evaluation may be made more robust.
Currently, this is only used by Application Passwords to prevent a conflict since it also utilizes Basic Auth.
Параметры
$context
string
необязательный
= ''
Возвращаемое значение
bool
Исходный код
wp-includes/load.php:2025
function wp_is_site_protected_by_basic_auth( $context = '' ) {
global $pagenow;
if ( ! $context ) {
if ( 'wp-login.php' === $pagenow ) {
$context = 'login';
} elseif ( is_admin() ) {
$context = 'admin';
} else {
$context = 'front';
}
}
$is_protected = ! empty( $_SERVER['PHP_AUTH_USER'] ) || ! empty( $_SERVER['PHP_AUTH_PW'] );
/**
* Filters whether a site is protected by HTTP Basic Auth.
*
* @since 5.6.1
*
* @param bool $is_protected Whether the site is protected by Basic Auth.
* @param string $context The context to check for protection. One of 'login', 'admin', or 'front'.
*/
return apply_filters( 'wp_is_site_protected_by_basic_auth', $is_protected, $context );
}
История изменений
| Версия | Описание |
|---|---|
| 5.6.1 | Introduced. |

