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.
Constants and properties
| private | REFUSALS = 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. |
| private | REFUSED = '<strong>Error:</strong> The username or password you entered is incorrect.' | The one sentence for any of them. |
| private | readonly array $notices | Promoted from the constructor. |
Public
| new | __construct(array $notices = array ( ))# |
| |||
| static | none(): self# | No notices. | |||
| static | plain(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. | |||
| static | refused(mixed $refusal): self# | A sign-in refused: the chain's refusal, or (none given, or not one) the engine's one sentence. | |||
| static | of(mixed $errors): self# | The notices a WP_Error holds (a plugin may have handed back something else: then none). | |||
| method | with(string $code, string $html, string $severity = ''): self# | These notices and one more. | |||
| method | isEmpty(): bool# | Whether there are none. | |||
| method | wpError(): WP_Error# | As the WP_Error plugins are handed. | |||
| method | forSignIn(string $redirect): self# | The sign-in page's notices after wp_login_errors, which is handed where a sign-in would land. | |||
| method | areas(): 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.
| private | words(string $text): string# | Plain words as notice HTML. |
Nothing matches.