PluginProbe
User Access Manager / 2.2.13
User Access Manager v2.2.13
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
← All changes | src/Controller/Frontend/LoginControllerTrait.php +70 -2 2.3.152.2.13 View file →
@@ -1,5 +1,18 @@
1 1 <?php
2 +/**
3 + * LoginControllerTrait.php
4 + *
5 + * The LoginControllerTrait trait file.
6 + *
7 + * PHP versions 5
8 + *
9 + * @author Alexander Schneider <alexanderschneider85@gmail.com>
10 + * @copyright 2008-2017 Alexander Schneider
11 + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2
12 + * @version SVN: $id$
13 + * @link http://wordpress.org/extend/plugins/user-access-manager/
14 + */
2 15
3 16 declare(strict_types=1);
4 17
5 18 namespace UserAccessManager\Controller\Frontend;
@@ -5,14 +18,36 @@
5 18 namespace UserAccessManager\Controller\Frontend;
6 19
7 20 use UserAccessManager\Wrapper\Wordpress;
8 21
22 +/**
23 + * Trait LoginControllerTrait
24 + *
25 + * @package UserAccessManager\Controller
26 + */
9 27 trait LoginControllerTrait
10 28 {
29 + /**
30 + * @return Wordpress
31 + */
11 32 abstract protected function getWordpress(): Wordpress;
33 +
34 + /**
35 + * @return string
36 + */
12 37 abstract public function getRequestUrl(): string;
13 - abstract public function getRequestParameter(string $name, mixed $default = null): mixed;
14 38
39 + /**
40 + * @param string $name
41 + * @param mixed $default
42 + * @return mixed
43 + */
44 + abstract public function getRequestParameter(string $name, $default = null);
45 +
46 + /**
47 + * Returns the user login name.
48 + * @return string
49 + */
15 50 public function getUserLogin(): string
16 51 {
17 52 $userLogin = $this->getRequestParameter('log');
18 53 return $this->getWordpress()->escHtml(stripslashes((string) $userLogin));
@@ -17,44 +52,77 @@
17 52 $userLogin = $this->getRequestParameter('log');
18 53 return $this->getWordpress()->escHtml(stripslashes((string) $userLogin));
19 54 }
20 55
56 + /**
57 + * Returns true if the user is logged in.
58 + * @return bool
59 + */
21 60 public function isUserLoggedIn(): bool
22 61 {
23 62 return $this->getWordpress()->isUserLoggedIn();
24 63 }
25 64
65 + /**
66 + * Returns the user name of the current user
67 + * @return string
68 + */
26 69 public function getCurrentUserName(): string
27 70 {
28 71 return $this->getWordpress()->getCurrentUser()->display_name;
29 72 }
30 73
74 + /**
75 + * Returns the login url.
76 + * @return string
77 + */
31 78 public function getLoginUrl(): string
32 79 {
33 80 return $this->getWordpress()->wpLoginUrl($this->getRequestUrl());
34 81 }
35 82
83 + /**
84 + * Returns the logout url.
85 + * @return string
86 + */
36 87 public function getLogoutUrl(): string
37 88 {
38 89 return $this->getWordpress()->wpLogoutUrl($this->getRequestUrl());
39 90 }
40 91
92 +
93 + /**
94 + * Returns the registration url.
95 + * @return string
96 + */
41 97 public function getRegistrationUrl(): string
42 98 {
43 99 return $this->getWordpress()->wpRegistrationUrl();
44 100 }
45 101
102 + /**
103 + * Returns the lost password url.
104 + * @return string
105 + */
46 106 public function getLostPasswordUrl(): string
47 107 {
48 108 return $this->getWordpress()->wpLostPasswordUrl($this->getRequestUrl());
49 109 }
50 110
111 + /**
112 + * Checks if we allowed show the login form.
113 + * @return bool
114 + */
51 115 public function showLoginForm(): bool
52 116 {
53 117 return $this->getWordpress()->isSingle() === true || $this->getWordpress()->isPage() === true;
54 118 }
55 119
56 - public function getRedirectLoginUrl(): mixed
120 + /**
121 + * Returns the login redirect url.
122 + * @return mixed
123 + */
124 + public function getRedirectLoginUrl()
57 125 {
58 126 $loginUrl = $this->getWordpress()->getBlogInfo('wpurl')
59 127 .'/wp-login.php?redirect_to='.urlencode($_SERVER['REQUEST_URI']);
60 128 return $this->getWordpress()->applyFilters('uam_login_url', $loginUrl);