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 +13 -10 10.2.2 → 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(string $email, string $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,19 +85,19 @@
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 102 function acym_currentUserEmail(int $userid = 0): string
101 103 {
@@ -103,12 +105,13 @@
103 105
104 106 return empty($user->user_email) ? '' : $user->user_email;
105 107 }
106 108
107 -function acym_replaceGroupTags($uploadFolder)
109 +function acym_replaceGroupTags(string $uploadFolder): string
108 110 {
109 111 if (strpos($uploadFolder, '{groupname}') === false) return $uploadFolder;
110 112
113 + // Get user groups
111 114 $groups = acym_getGroupsByUser(acym_currentUserId());
112 115 $group = array_shift($groups);
113 116
114 117 $uploadFolder = str_replace(
@@ -119,8 +122,8 @@
119 122
120 123 return $uploadFolder;
121 124 }
122 125
123 -function acym_getCmsUserEdit($userId)
126 +function acym_getCmsUserEdit(int $userId): string
124 127 {
125 128 return 'user-edit.php?user_id='.intval($userId);
126 129 }