PluginProbe
User Access Manager / 2.3.16
User Access Manager v2.3.16
2.3.20 2.3.19 2.3.18 2.3.17 2.3.16 2.3.15 2.3.14 2.3.13 trunk 0.6 0.6.1 0.6.2 0.7 0.7 Beta 0.7.0.1 0.8 0.8.0.1 0.8.0.2 0.9 0.9.1 0.9.1.1 0.9.1.2 0.9.1.3 0.9.1.4 1.0 All 136 releases
user-access-manager / src / Controller / Frontend / LoginControllerTrait.php

LoginControllerTrait.php in User Access Manager 2.3.16, at src/Controller/Frontend/LoginControllerTrait.php

63 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace UserAccessManager\Controller\Frontend;
6
7 use UserAccessManager\Wrapper\Wordpress;
8
9 trait LoginControllerTrait
10 {
11 abstract protected function getWordpress(): Wordpress;
12 abstract public function getRequestUrl(): string;
13 abstract public function getRequestParameter(string $name, mixed $default = null): mixed;
14
15 public function getUserLogin(): string
16 {
17 $userLogin = $this->getRequestParameter('log');
18 return $this->getWordpress()->escHtml(stripslashes((string) $userLogin));
19 }
20
21 public function isUserLoggedIn(): bool
22 {
23 return $this->getWordpress()->isUserLoggedIn();
24 }
25
26 public function getCurrentUserName(): string
27 {
28 return $this->getWordpress()->getCurrentUser()->display_name;
29 }
30
31 public function getLoginUrl(): string
32 {
33 return $this->getWordpress()->wpLoginUrl($this->getRequestUrl());
34 }
35
36 public function getLogoutUrl(): string
37 {
38 return $this->getWordpress()->wpLogoutUrl($this->getRequestUrl());
39 }
40
41 public function getRegistrationUrl(): string
42 {
43 return $this->getWordpress()->wpRegistrationUrl();
44 }
45
46 public function getLostPasswordUrl(): string
47 {
48 return $this->getWordpress()->wpLostPasswordUrl($this->getRequestUrl());
49 }
50
51 public function showLoginForm(): bool
52 {
53 return $this->getWordpress()->isSingle() === true || $this->getWordpress()->isPage() === true;
54 }
55
56 public function getRedirectLoginUrl(): mixed
57 {
58 $loginUrl = $this->getWordpress()->getBlogInfo('wpurl')
59 .'/wp-login.php?redirect_to='.urlencode($_SERVER['REQUEST_URI']);
60 return $this->getWordpress()->applyFilters('uam_login_url', $loginUrl);
61 }
62 }
63