in_array( $type, self::TYPES, true ) ? $type : 'info', 'message' => $message, ), self::TTL ); } /** * Print and forget the queued notice. * * @return void */ public static function render(): void { $notice = get_transient( self::key() ); if ( ! is_array( $notice ) ) { return; } delete_transient( self::key() ); printf( '

%2$s

', esc_attr( $notice['type'] ), esc_html( $notice['message'] ) ); } /** * Transient key for the current user. * * @return string */ private static function key(): string { return self::PREFIX . get_current_user_id(); } }