WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Авторские Темы для WordPress
функция не описана

wp_is_site_protected_by_basic_auth() WP 5.6.1

Checks if this site is protected by HTTP 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.

Хуки из функции
Возвращает

true|false. Whether the site is protected by Basic Auth.

Использование

wp_is_site_protected_by_basic_auth( $context );
$context(строка)
The context to check for protection. Accepts 'login', 'admin', and 'front'.
По умолчанию: current context

Заметки

  • Global. Строка. $pagenow The current page.

Список изменений

С версии 5.6.1 Введена.

Код wp_is_site_protected_by_basic_auth() WP 5.7.2

<?php
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 );
}