PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.0
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.0
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
← All changes | back/Core/wordpress/user.php +16 -19 10.0.1 → 11.1.0 View file →
@@ -1,6 +1,8 @@
1 1 <?php
2 2
3 +defined('ABSPATH') || die('Restricted Access');
4 +
3 5 use AcyMailing\Core\AcymPunycode;
4 6
5 7 global $acymCmsUserVars;
6 8 $acymCmsUserVars = new stdClass();
@@ -11,9 +13,9 @@
11 13 $acymCmsUserVars->email = 'user_email';
12 14 $acymCmsUserVars->registered = 'user_registered';
13 15 $acymCmsUserVars->blocked = 'user_status';
14 16
15 -function acym_getGroupsByUser($userid = null, $recursive = null, $names = false)
17 +function acym_getGroupsByUser(?int $userid = null, ?bool $recursive = null, bool $names = false): array
16 18 {
17 19 if ($userid === null) {
18 20 $user = wp_get_current_user();
19 21 } else {
@@ -19,9 +21,9 @@
19 21 } else {
20 22 $user = new WP_User($userid);
21 23 }
22 24
23 - if (is_multisite() && is_super_admin()) {
25 + if (is_multisite() && is_super_admin($user->ID)) {
24 26 return ['administrator'];
25 27 }
26 28
27 29 return $user->roles;
@@ -26,9 +28,9 @@
26 28
27 29 return $user->roles;
28 30 }
29 31
30 -function acym_getGroups()
32 +function acym_getGroups(): array
31 33 {
32 34 $roles = wp_roles();
33 35 if (empty($roles->roles)) {
34 36 $groups = acym_loadResult('SELECT option_value FROM #__options WHERE option_name = "#__user_roles"');
@@ -52,15 +54,15 @@
52 54
53 55 return $groups;
54 56 }
55 57
56 -function acym_punycode($email, $method = 'emailToPunycode')
58 +function acym_punycode(string $email, string $method = 'emailToPunycode'): string
57 59 {
58 60 if (empty($email) || acym_isPunycode($email)) {
59 61 return $email;
60 62 }
61 63
62 - $explodedAddress = explode('@', $email);
64 + $explodedAddress = explode('@', $email, 2);
63 65 $newEmail = $explodedAddress[0];
64 66
65 67 if (!empty($explodedAddress[1])) {
66 68 $domainExploded = explode('.', $explodedAddress[1]);
@@ -83,38 +85,33 @@
83 85 {
84 86 return intval(get_current_user_id());
85 87 }
86 88
87 -function acym_currentUserName($userid = null)
89 +function acym_currentUserName(?int $userid = null): string
88 90 {
89 91 if (!empty($userid)) {
90 92 $special = get_user_by('id', $userid);
91 93
92 - return $special->display_name;
94 + return empty($special->display_name) ? '' : $special->display_name;
93 95 }
94 96
95 97 $current_user = wp_get_current_user();
96 98
97 - return $current_user->display_name;
99 + return empty($current_user->display_name) ? '' : $current_user->display_name;
98 100 }
99 101
100 -function acym_currentUserEmail($userid = null)
102 +function acym_currentUserEmail(int $userid = 0): string
101 103 {
102 - if (!empty($userid)) {
103 - $special = get_user_by('id', $userid);
104 + $user = empty($userid) ? wp_get_current_user() : get_user_by('id', $userid);
104 105
105 - return $special->user_email;
106 - }
107 -
108 - $current_user = wp_get_current_user();
109 -
110 - return $current_user->user_email;
106 + return empty($user->user_email) ? '' : $user->user_email;
111 107 }
112 108
113 -function acym_replaceGroupTags($uploadFolder)
109 +function acym_replaceGroupTags(string $uploadFolder): string
114 110 {
115 111 if (strpos($uploadFolder, '{groupname}') === false) return $uploadFolder;
116 112
113 + // Get user groups
117 114 $groups = acym_getGroupsByUser(acym_currentUserId());
118 115 $group = array_shift($groups);
119 116
120 117 $uploadFolder = str_replace(
@@ -125,8 +122,8 @@
125 122
126 123 return $uploadFolder;
127 124 }
128 125
129 -function acym_getCmsUserEdit($userId)
126 +function acym_getCmsUserEdit(int $userId): string
130 127 {
131 128 return 'user-edit.php?user_id='.intval($userId);
132 129 }