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