PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.1
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 +0 -129 trunk → 11.1.1 View file →
@@ -1,129 +1,0 @@
1 -<?php
2 -
3 -defined('ABSPATH') || die('Restricted Access');
4 -
5 -use AcyMailing\Core\AcymPunycode;
6 -
7 -global $acymCmsUserVars;
8 -$acymCmsUserVars = new stdClass();
9 -$acymCmsUserVars->table = '#__users';
10 -$acymCmsUserVars->name = 'display_name';
11 -$acymCmsUserVars->username = 'user_login';
12 -$acymCmsUserVars->id = 'ID';
13 -$acymCmsUserVars->email = 'user_email';
14 -$acymCmsUserVars->registered = 'user_registered';
15 -$acymCmsUserVars->blocked = 'user_status';
16 -
17 -function acym_getGroupsByUser(?int $userid = null, ?bool $recursive = null, bool $names = false): array
18 -{
19 - if ($userid === null) {
20 - $user = wp_get_current_user();
21 - } else {
22 - $user = new WP_User($userid);
23 - }
24 -
25 - if (is_multisite() && is_super_admin($user->ID)) {
26 - return ['administrator'];
27 - }
28 -
29 - return $user->roles;
30 -}
31 -
32 -function acym_getGroups(): array
33 -{
34 - $roles = wp_roles();
35 - if (empty($roles->roles)) {
36 - $groups = acym_loadResult('SELECT option_value FROM #__options WHERE option_name = "#__user_roles"');
37 - if (!empty($groups)) {
38 - $groups = unserialize($groups);
39 - } else {
40 - $groups = [];
41 - }
42 - } else {
43 - $groups = $roles->roles;
44 - }
45 -
46 - foreach ($groups as $key => $group) {
47 - $newGroup = new stdClass();
48 - $newGroup->id = $key;
49 - $newGroup->value = $key;
50 - $newGroup->parent_id = 0;
51 - $newGroup->text = translate_user_role($group['name']);
52 - $groups[$key] = $newGroup;
53 - }
54 -
55 - return $groups;
56 -}
57 -
58 -function acym_punycode(string $email, string $method = 'emailToPunycode'): string
59 -{
60 - if (empty($email) || acym_isPunycode($email)) {
61 - return $email;
62 - }
63 -
64 - $explodedAddress = explode('@', $email, 2);
65 - $newEmail = $explodedAddress[0];
66 -
67 - if (!empty($explodedAddress[1])) {
68 - $domainExploded = explode('.', $explodedAddress[1]);
69 - $newdomain = '';
70 - $puc = new AcymPunycode();
71 -
72 - foreach ($domainExploded as $domainex) {
73 - $domainex = $puc->$method($domainex);
74 - $newdomain .= $domainex.'.';
75 - }
76 -
77 - $newdomain = substr($newdomain, 0, -1);
78 - $newEmail = $newEmail.'@'.$newdomain;
79 - }
80 -
81 - return $newEmail;
82 -}
83 -
84 -function acym_currentUserId(): int
85 -{
86 - return intval(get_current_user_id());
87 -}
88 -
89 -function acym_currentUserName(?int $userid = null): string
90 -{
91 - if (!empty($userid)) {
92 - $special = get_user_by('id', $userid);
93 -
94 - return empty($special->display_name) ? '' : $special->display_name;
95 - }
96 -
97 - $current_user = wp_get_current_user();
98 -
99 - return empty($current_user->display_name) ? '' : $current_user->display_name;
100 -}
101 -
102 -function acym_currentUserEmail(int $userid = 0): string
103 -{
104 - $user = empty($userid) ? wp_get_current_user() : get_user_by('id', $userid);
105 -
106 - return empty($user->user_email) ? '' : $user->user_email;
107 -}
108 -
109 -function acym_replaceGroupTags(string $uploadFolder): string
110 -{
111 - if (strpos($uploadFolder, '{groupname}') === false) return $uploadFolder;
112 -
113 - // Get user groups
114 - $groups = acym_getGroupsByUser(acym_currentUserId());
115 - $group = array_shift($groups);
116 -
117 - $uploadFolder = str_replace(
118 - '{groupname}',
119 - strtolower(str_replace(' ', '_', $group)),
120 - $uploadFolder
121 - );
122 -
123 - return $uploadFolder;
124 -}
125 -
126 -function acym_getCmsUserEdit(int $userId): string
127 -{
128 - return 'user-edit.php?user_id='.intval($userId);
129 -}