Automattic\WooCommerce\Internal\Abilities
AbilitiesTracking::get_auth_method
Identify how the caller authenticated, so agents can be told apart from people in wp-admin.
Метод класса: AbilitiesTracking{}
Хуков нет.
Возвращает
string. application_password, jetpack, cookie, other (another REST authentication method) or none (logged out, WP-CLI or cron).
Использование
$result = AbilitiesTracking::get_auth_method(): string;
Код AbilitiesTracking::get_auth_method() AbilitiesTracking::get auth method WC 11.3.0
private static function get_auth_method(): string {
if ( function_exists( 'rest_get_authenticated_app_password' ) && rest_get_authenticated_app_password() ) {
return 'application_password';
}
if ( self::is_jetpack_signed_request() ) {
return 'jetpack';
}
if ( ! is_user_logged_in() || ( defined( 'WP_CLI' ) && WP_CLI ) || wp_doing_cron() ) {
return 'none';
}
if ( wp_is_serving_rest_request() ) {
global $wp_rest_auth_cookie;
return true === $wp_rest_auth_cookie ? 'cookie' : 'other';
}
return 'cookie';
}