API / Minn\Login / LoginNotices

LoginNotices final readonly class

Minn\Login\LoginNotices · public/minn/src/Minn/Login/LoginNotices.php · 113 lines

What a sign-in page tells the reader, held as the reference's pages hold it: notices by code, each an error or (severity "message") a message, their words as HTML. Printed, the errors are one paragraph, or a list when there are several, and the messages a paragraph each; with plugins loaded the sign-in page hands them through wp_login_errors first, and every page prints them through login_errors and login_messages. The authenticate chain's own refusals read as the engine's one sentence, so a page never says which half of a sign-in was wrong.

Uses 1

Constants and properties

privateREFUSALS = array ( 0 => 'empty_username', 1 => 'empty_password', 2 => 'invalid_username', 3 => 'invalid_email', 4 => 'incorrect_password', 5 => 'authentication_failed', )

The chain's own refusals, which the page words as one.

privateREFUSED = '<strong>Error:</strong> The username or password you entered is incorrect.'

The one sentence for any of them.

privatereadonly array $notices

Promoted from the constructor.

Public

new__construct(array $notices = array ( ))#
$noticeslist<array{0: string, 1: string, 2: string}>code, HTML, severity ('' or 'message')
staticnone(): self#

No notices.

staticplain(string $code, string $text, string $severity = ''): self#

The engine's own plain words as one notice; an "Error:" lead takes the reference's strong label.

staticrefused(mixed $refusal): self#

A sign-in refused: the chain's refusal, or (none given, or not one) the engine's one sentence.

staticof(mixed $errors): self#

The notices a WP_Error holds (a plugin may have handed back something else: then none).

methodwith(string $code, string $html, string $severity = ''): self#

These notices and one more.

methodisEmpty(): bool#

Whether there are none.

methodwpError(): WP_Error#

As the WP_Error plugins are handed.

methodforSignIn(string $redirect): self#

The sign-in page's notices after wp_login_errors, which is handed where a sign-in would land.

methodareas(): array#

The error and message areas' HTML ('' for an area with none), through login_errors and login_messages.

@return array{errors: string, messages: string}

Internals 1

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatewords(string $text): string#

Plain words as notice HTML.