rest_application_password_check_errors()

最后更新于:2021-11-27 23:33:00

rest_application_password_check_errors( GC_Error|null|true$result)

Checks for errors when using application password-based authentication.

参数

$result

(GC_Error|null|true) (Required) Error from another authentication handler, null if we should handle it, or another value if not.

响应

(GC_Error|null|true) GC_Error if the application password is invalid, the $result, otherwise true.

源文件

文件: gc-includes/rest-api.php

function rest_application_password_check_errors( $result ) {
	global $gc_rest_application_password_status;

	if ( ! empty( $result ) ) {
		return $result;
	}

	if ( is_gc_error( $gc_rest_application_password_status ) ) {
		$data = $gc_rest_application_password_status->get_error_data();

		if ( ! isset( $data['status'] ) ) {
			$data['status'] = 401;
		}

		$gc_rest_application_password_status->add_data( $data );

		return $gc_rest_application_password_status;
	}

	if ( $gc_rest_application_password_status instanceof GC_User ) {
		return true;
	}

	return $result;
}